[aspectc-user] Element counter example -- getting compile error
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Thu May 27 09:48:05 CEST 2004
Hi,
siva chelliah wrote:
>
>
> Hi,
>
> I am trying to test the code in the tutorial and getting a compile
> error. I am using AC++ 0.8.1 on windows 2000 system. I am also using
> Borland c++ compiler.
>
>
>
> C:\workspace>ac++ -p Queue -d Queue-out -IQueue -v 9
>
> * Running ac++ 0.8.1
>
> * Simple Dependency Check
>
> - new or modified: Queue/ElementCounter.ah
>
> - new or modified: Queue/ErrorAspect.ah
>
> * Handling Translation Unit `main.cc'.
>
> - Path "Queue/main.cc"
>
> - Inserting namespace AC
>
> - Parsing ...
>
> Queue/ElementCounter.ah(12): error: invalid member declaration near
> token `Queue
>
>
>
> Here is the complete file:
>
>
>
> aspect ElementCounter
>
> {
>
> //int counter;
>
> private:
>
> advice "Queue" : int counter;
>
>
>
> public:
>
>
>
> advice "Queue" : int count() { return counter; } ß typo in the
> tutorial[ int count instead of int count()]
thanks.
> advice execution("% Queue::enqueue(...)")
>
> && that(queue) : after(Queue& queue ) ß------------ this is
> the error line
Two problems:
1. You use the name 'q' and not 'queue' in the advice body.
2. To use the class 'Queue' you have to include the header file
that contains the class definition. This is not shown on the
tutorial slides to save space.
> {
>
> ++q.counter;
>
> printf("num ele after enqueue = %d\n", q.count());
>
> }
>
>
>
> advice execution("% Queue::dequeue(...)")
>
> && that(q) : after( Queue& q )
>
> {
>
> if (q.count() > 0) {
>
> --q.counter;
>
> }
>
> printf("num ele after dequeue %d\n", q.count());
>
> }
>
> };
>
>
>
> Please help.
>
>
>
> /Siva Chelliah/
>
> /Samsung Telecommunications //America/
>
> *1301 East Lookout Dr**. **Richardson**, **TX** **75082*
>
> /972-761-7903 (fax: 7909)/
>
> /_A conclusion is simply the place where someone got tired of thinking_/
To avoid problems like this in the future I'll upload the example code
from the tutorial to our web site today.
By the way, do you use Borland C++ only for trying AspectC++ or is it
your preferred compiler in your daily business? My reason for asking
this is that we are considering to discontinue support for Borland C++.
There are several problems with this back-end compiler and Windows users
could also work with g++ or VisualC++ (the command line version is even
freely available now).
Best regards,
Olaf
More information about the aspectc-user
mailing list