[aspectc-user] Newbie needs help
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Nov 16 15:30:44 CET 2004
Hi Marko,
Marko Bozikovic wrote:
> Hi!
>
> I've started playing with AspectC++, and I'm having some problems with
> that(). Here's the aspect code:
>
>
> -- begin code
>
> #include <iostream>
> using namespace std;
>
> #include "a.h"
>
> pointcut new_A(class A& a) = construction("A") && that(a);
> pointcut exec_A(class A& a) = execution("% A::exec(...)") && that(a);
>
> aspect CounterA {
>
> private:
> advice "A" : int nCounter;
>
> public:
> advice new_A(a) : after(class A& a) {
> a.nCounter = 0;
> cout << "Creating A: " << a.nCounter << endl;
> }
>
> advice exec_A(a) : after(class A& a) {
> ++a.nCounter;
> cout << "Executing A: " << a.nCounter << endl;
> }
> };
>
> -- end code
>
>
> Now, when I compile this (AspectC++ 0.9 on linux), I get errors:
>
> main.ah:6: error: `a' undeclared here
> main.ah:7: error: `a' undeclared here
>
>
> According to the language reference, that() needs a type pattern -
> that(type pattern). Using 'that("A")' on lines 6 and 7, I get errors:
>
> main.ah:1: error: Include recursion too deep (400)
> main.ah:4: error: Include recursion too deep (400)
>
> a.h defines a class A, that has ctor, dtor and void exec() function.
>
> What am I doing wrong?
>
> TIA,
try it again with include guards (#ifndef __main_ah__ .. #define
__main_ah__ .. code .. #endif) in all your header and aspect header files.
Olaf
More information about the aspectc-user
mailing list