[aspectc-user] Some questions

Fabian Scheler fabian.scheler at gmail.com
Wed Sep 14 15:49:06 CEST 2005


 Hi, > I had a problem of double definition of classes in .ah files when compiling.> It was solved by including guards (#ifndef …) in .ah files. I noticed that> in the examples no guards are used. Should them be used or inserted by ac++> ?
no, you have to insert them by your own. The examples provided alongwith ac++ 0.9.3 are that small, that none of the headers is includedtwice, so the include guard could be left out
> Does AspectC++ work with templates? I have a class with templates and> declared a method as a join point. No error was issued during weaving but> the code wasn't affected.
You can use templates within aspects and advice code, for moreinformation seehttp://www4.informatik.uni-erlangen.de/~lohmann/download/GPCE04_Lohmann.pdf.In the current version it is not possible to weave advice code intotemplate code and it probably never will, but a similar feature willbe available in one of the future versions of ac++ (as far as I know):ac++ will be able to weave advice into concrete template instances,the template instantiation itself will also be performed by ac++ (formore information see http://www.aspectc.org/Roadmap.16.0.html)
> My project has some C code in files .c. Can I use AOP with them? I noticed> that they are not copied to the destination directory.
That your .c files are not touched is caused by a missing -e option.The -e option tells ac++ which files in the source tree are the files,that should be woven. This option is only valid in WPT-Mode not inSTU-Mode and defaults to .cc.ac++ is indeed able to weave code advice also into C code, but theconstructs used to implement the AspectC++ features are C++ languageconstructs. That means that the woven code has to be compiled with aC++ compiler.
> Can I use global variables inside the advice code?
As long as they are visible within the advice code - yes!
> In the around advice without using proceed() how can I return a value?
You can not specify something like a return statement within in anytype of code advice in AspectC++, but you can alter the value thatwill be returned by the affected function wih the help of theJoinPoint-API: tjp->result() is what you are looking for. For moreinformation: language reference.
Ciao, Fabian



More information about the aspectc-user mailing list