[aspectc-user] Help Needed
Thirunavukkarasu, Ramasamy (IE10)
Thirunavukkarasu.Ramasamy at honeywell.com
Mon Feb 4 06:11:47 CET 2002
Hi,
I wrote an aspect file and a cc file whose code is given below:
aspect file
#include<stdio.h>
aspect methodfunctions
{
pointcut move() = execution("% Maths::calladd(...)");
public:
advice move() : void before()
{
printf("ID OF THE JOIN POINT = %d ",
thisJoinPoint->id());
}
};
cc file
# include<stdio.h>
class Maths
{
public:
int tmpNum1;
int tmpNum2;
public:
Maths(int Num1, int Num2)
{
tmpNum1 = Num1;
tmpNum2 = Num2;
}
int calladd()
{
return(tmpNum1+tmpNum2);
}
int callsub()
{
return(tmpNum1 - tmpNum2);
}
int callmul()
{
return(tmpNum1*tmpNum2);
}
};
int main()
{
Maths math(4,3);
int add1;
int sub1;
int mul1;
add1 = math.calladd();
sub1 = math.callsub();
mul1 = math.callmul();
printf("%d %d %d", add1, sub1, mul1 );
}
Using the ac++ compiler weaving happens, but when I run the transformed cc
file, it fails. I have given the transformed code generated by the ac++
compiler.
Transformed cc code
#include "methodfunctions.ah"
# include<stdio.h>
class Maths
{
public:
int tmpNum1;
int tmpNum2;
public:
Maths(int Num1, int Num2)
{
tmpNum1 = Num1;
tmpNum2 = Num2;
}
int __old_calladd()
{
return(tmpNum1+tmpNum2);
}
int calladd ()
{
static methodfunctions::__Tjps__advice_0 __tjp_methodfunctions__advice_0
(, 0);
methodfunctions::aspectOf ()->methodfunctions::__advice_0
(&__tjp_methodfunctions__advice_0);
int result = __old_calladd ();
return result;
}
int callsub()
{
return(tmpNum1 - tmpNum2);
}
int callmul()
{
return(tmpNum1*tmpNum2);
}
};
int main()
{
Maths math(4,3);
int add1;
int sub1;
int mul1;
add1 = math.calladd();
sub1 = math.callsub();
mul1 = math.callmul();
printf("%d %d %d", add1, sub1, mul1 );
}
The errors reported are:
methodfunctions.cc: In method `int Maths::calladd()':
methodfunctions.cc:27: parse error before `,'
methodfunctions.cc:27: cannot declare static function inside another
function
methodfunctions.cc:28: no matching function for call to
`methodfunctions::__advi
ce_0 (methodfunctions::__Tjps__advice_0 (*)(...))'
methodfunctions.ah:30: candidates are:
methodfunctions::__advice_0(methodfunctio
ns::__Tjps__advice_0 *)
make: *** [trace] Error 1
Can anyone help me tracing what the problem could be ?
Thanks in advance,
Thiruna
More information about the aspectc-user
mailing list