[aspectc-user] error when using templates in aspects

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Wed Feb 1 16:44:13 CET 2006


Hi Gabriel,

there is nothing wrong with your code. It is a bug. The weaver inserts a 
forward declaration of the aspect in front of the template definition. 
It does not detect that this is a nested (template) class definition 
where this makes no sense.

As a workaround you could move the template class definition in front of 
the aspect into the global scope.

Thank you for reporting this problem.

- Olaf

BTW. don't forget to use include guards in your aspect header and use 
--real-instances if you want to play with templates (on Linux).

gabrielalexm at yahoo.com wrote:
> Hi,
> I want to try some of the generative programming ideas
> as described in the SD Journal article and I found a
> problem.
> I can reproduce it with these two files:
> -------- hello.cpp -------------
> #include <iostream>
> 
> int main () {
>     std::cout << "Hello World!" << std::endl;
> }
> -------- end hello.cpp ---------
> 
> -------- myAspect.ah -----------
> #include <iostream>
> 
> aspect myAspect {
> 
> 	template<class TJP>
> 	class MyClass {
> 	};
> 
>     advice execution( "% main(...)" ) : before () {
>       std::cout << "Hello Aspect! " <<
> JoinPoint::signature() << std::endl;
>     }
> };
> -------- end myAspect.ah -------
> 
> I'm compiling this using ac-1.0pre2 on Linux, using
> the command line:
> ag++ hello.cpp -o hello
> I get the following error:
> hello.acc:182: error: ‘class myAspect’ has the same
> name as the class in which it is declared
> 
> If I comment the template definition out, it compiles
> and works fine.
> 
> What am I doing wrong?
> 
> Thanks,
> Gabriel
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> aspectc-user mailing list
> aspectc-user at aspectc.org
> http://www.aspectc.org/mailman/listinfo/aspectc-user




More information about the aspectc-user mailing list