[aspectc-user] How to introduce a method into a class ??
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Jul 27 17:45:57 CEST 2004
Hello Jean,
Jean J wrote:
> Hello,
>
> I am trying to introduce some variables and methods
> into a class using AspectC++. As i read into the
> quickref for aspectC++ "if the advice is not
> recognized of being of a predefined kind, is is
> regarded as an introduction of a new method,
> attribute, or type ..."
>
> my code is the following :
>
>
> aspect TEST {
>
> advice "Class1" : void do_some_work() {
> cout << "doing some work" << endl;
> return;
> }
> };
>
>
> But i get an error with ac++ :
>
> In file included from ac_gen.cc:32:
> test.ah:3: syntax error before `{'
> ac_gen.cc:7: syntax error before `::'
>
> Is the syntax of my method introduction ok or not ?
> any suggestions ?
>
> Thanks.
The syntax looks OK. Do you have something like ...
#include <iostream>
using std::cout;
using std::endl;
... in your aspect header? You have to make sure that every object,
which is referenced by the introduced code, is known in every affected
translation unit. The best way to achieve this goal is to include the
respective header files in the aspect header.
However, I doubt that this is the problem here.
If you have a simple example, don't hesitate to send me the code.
Olaf
More information about the aspectc-user
mailing list