[aspectc-user] adding variables and using them

Jamal Siadat siadat at cpsc.ucalgary.ca
Sat Jul 16 00:35:11 CEST 2005

Hi, Thanks for the information but I'm still having segmentation fault.
I'm using the following files:

class A {
    A(int x);
    int r (int x);
  int j;
  int a(const char *name, float b);
  int p;


A::A(int x) {j=x; }

int A::a( const char *name, float b) {

   int jam=7;
 printf("inside A::a( %f)\n",  b);

return jam;}

int main (){
 A b(5);
 return 0;}

and the aspect asp.ah is defined below with tjp->that()->abc=0 ( I also
used tjp->target()->abc=0. If I delete the construction advice it would go
away but it has a seg fault in this condition.. anyway to get around it?
Thanks again :)
P.S: could it be because the constructor takes a parameter?

>> and second, would the following make any sense? I'm trying to add the
>> variable that I just created for the class to the constructor. I know it
>> wouldnt allow me to touch the constructor using regular advices so I'm
>> wondering if this would work( although the compiler is complaining and
>> gicing segmentaion faults)
>> aspect asp :public A {
>> public:
>> asp(int ix):A(ix){} //assume A(int x) is constructor
>> pointcut calls()=  "A" ;
>> advice calls() : void initialize () {p=0;j=0;}
>> advice calls(): int abc;
>> advice construction (calls()) :before(){ abc=0;}
>> static asp* aspectof() {
>>   static asp asp_instance(5);
>>   return &asp_instance;
>> }};
> I think that should work, but again you have to use 'tjp->that()->abc
> = 0' instead of 'abc = 0'. In fact this quite common: insert a
> variable via an introduction and initialize it via
> construction-advice.
>> Thanks again Fabian,
>> Promise not to bother you as often :)
> No problem, I hope I was able to help you, but please always reply to
> the mailing list, too, so all readers of the mailing list can partake
> in a particular thread.
> Ciao, Fabian.

More information about the aspectc-user mailing list