[aspectc-user] Re: aspectc-user Digest, Vol 2, Issue 1

Olaf Spinczyk os at aspectc.org
Thu Jun 10 18:00:53 CEST 2010


Hi Bin Du!

The problem with your code is that an aspect can't call a function that 
is not declared. Your advice code calls func2(), but no declaration of 
func2() is visible when ac++ parses the aspect header file. Don't think 
of advice code as code that is textually inserted at the affected join 
point. It's more like an ordinary method of an ordinary class. If you 
want to call some function, include its declaration or use a forward 
declaration.

Inserting the following forward declaration in test.ah fixes your program:

void func2();

Furthermore, never forget to use an include guard in your aspect header 
files.

Best regards,

Olaf

Bin Du wrote:
> Hallo,
> danke für Ihre Antwort. Ja, "}"  habe ich vergessen, aber nur auf mail.
> Ich habe noch einmal getestet, leider tretet die gleiche Fehlermeldung
> auf. Ich nutze ac++ Version 1.0.0.3 mit
>
> D:\ac++>ac++ -p examples\test -d examples\test-out -Iexamples\test -v9
> * Running ac++ 1.0pre3
> * Simple Dependency Check
>   - new or modified: examples/test/test.ah
> * Handling Translation Unit `main.cc'.
>   - Path "examples/test/main.cc"
>   - Inserting namespace AC
>   - Parsing ...
>   - Setting Aspect Access Priviledges ...
>   - Weaving Introductions ...
>   - intros for test
>   - Aspect ordering ...
>   - Final checks before weaving introductions
>   - Class Join Points
>   - Weaving Advice Declarations ...
>     test::%a0_before
>   - Weaving Singleton Aspects ...
>   - Slice/Intro Includes ...
>   - Commiting
>   - Parsing again ...
>   - Weaving Join Points ...
>     Advicecode manipulation
>     Collecting Advice
>       Setting up thisJoinPoint for aspectof
>       Supplying aspectof() with JoinPoint and tjp if needed
>       test: __a0_before
>         Evaluate Pointcut
>     Aspect ordering ...
>     Final checks before weaving code join points
>     Type Check Functions
>     Call Join Points
>     Execution Join Points
>       void func1()
>     Construction Join Points
>     Destruction Join Points
>   - Aspect Includes ...
>   - Final cleanup
>   - Commiting
> * Handling include files
>   - Handling Translation Unit `ac_gen.cc'.
>     Path "examples/test/ac_gen.cc"
>     Inserting namespace AC
>     Parsing ...
>     Setting Aspect Access Priviledges ...
>     Weaving Introductions ...
>     intros for test
>     Aspect ordering ...
>     Final checks before weaving introductions
>     Class Join Points
>     Weaving Advice Declarations ...
>       test::%a0_before
>     Weaving Singleton Aspects ...
>     Slice/Intro Includes ...
>     Commiting
>     Parsing again ...
> examples/test/test.ah:10: error: `func2' undeclared here
>     Aborting
>
> ich kopere die testcode noch einmal hier
>
> ---------------------main.cc--------------------------
>
> #include <stdio.h>
>
> void func1 ( ) { };
> void func2 ( ) { };
> int main ( ) {
>                    func1 ( );
>                  //func2 ( );
> };
>
>
> ---------------------test.ah-------------------------------
>
> #include <stdio.h>
>
> aspect test {
>
> public:
>
>  advice execution("% func1 (...) ") : before () {
>        func2 ( );
>        }
> };
> --------------------------------------------
> am Beispiel2 ich ähnliches Problem.
>
> Gruss
> Du Bin
>
>
>
>
> 2010/4/1 <aspectc-user-request at aspectc.org 
> <mailto:aspectc-user-request at aspectc.org>>
>
>     Send aspectc-user mailing list submissions to
>            aspectc-user at aspectc.org <mailto:aspectc-user at aspectc.org>
>
>     To subscribe or unsubscribe via the World Wide Web, visit
>            http://www.aspectc.org/mailman/listinfo/aspectc-user
>     or, via email, send a message with subject or body 'help' to
>            aspectc-user-request at aspectc.org
>     <mailto:aspectc-user-request at aspectc.org>
>
>     You can reach the person managing the list at
>            aspectc-user-owner at aspectc.org
>     <mailto:aspectc-user-owner at aspectc.org>
>
>     When replying, please edit your Subject line so it is more specific
>     than "Re: Contents of aspectc-user digest..."
>
>
>     Today's Topics:
>
>       1. function call (Bin Du)
>       2. Re: function call (Olaf Spinczyk)
>
>
>     ----------------------------------------------------------------------
>
>     Message: 1
>     Date: Thu, 1 Apr 2010 11:19:26 +0200
>     From: Bin Du <bin.du.rbst at gmail.com <mailto:bin.du.rbst at gmail.com>>
>     Subject: [aspectc-user] function call
>     To: aspectc-user at aspectc.org <mailto:aspectc-user at aspectc.org>
>     Message-ID:
>          
>      <z2jcd5eff181004010219o463b7eb8w3d1f4194692516e9 at mail.gmail.com
>     <mailto:z2jcd5eff181004010219o463b7eb8w3d1f4194692516e9 at mail.gmail.com>>
>     Content-Type: text/plain; charset="iso-8859-1"
>
>     hi all,
>     i have a question, haw can i call a c++ function in aspectc++
>
>     -------------main.cc----------------------
>
>     void func1 ( ) { ... };
>     void func2 ( ) { ... };
>     int main ( ) {
>                        func1 ( );
>                      //func2 ( );
>     }
>
>     -----------test.ah--------------------
>
>     aspect test{
>      advice execution("% func1 (...) ") : before () {
>            func2 ( );
>     };
>
>     ac++ issues the error:
>                                     error: `func2' undeclared here
>
>
>     ----------------------- main2.cc-----------------
>
>     class Base1
>     {
>     public:
>       void ba1 ()
>        {
>         printf("Base2::b1 ()\n");
>        }
>     }base1;
>
>     class Base
>     {
>     public:
>
>        int b2 (inti)
>        {   inttemp = i;
>            return temp;
>        }
>     } *a ;
>
>     int main()
>     {
>
>        a->b2(0);
>
>        //base1.b1(); same problem
>
>        return 0;
>     }
>
>     Thanks in advance,
>     du bin
>     -------------- next part --------------
>     An HTML attachment was scrubbed...
>     URL:
>     http://www.aspectc.org/pipermail/aspectc-user/attachments/20100401/6a2fe785/attachment-0001.html
>
>     ------------------------------
>
>     Message: 2
>     Date: Thu, 01 Apr 2010 11:45:45 +0200
>     From: Olaf Spinczyk <os at aspectc.org <mailto:os at aspectc.org>>
>     Subject: Re: [aspectc-user] function call
>     To: aspectc-user at aspectc.org <mailto:aspectc-user at aspectc.org>
>     Message-ID: <4BB46B49.50703 at aspectc.org
>     <mailto:4BB46B49.50703 at aspectc.org>>
>     Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>     Hello!
>
>     I tested your first example and it works here.
>
>     Have you noticed that the closing bracket "}" of your advice code is
>     missing?
>
>     In the second example the call goes to b1(), but the function is named
>     ba1().
>
>     Best regards,
>
>     Olaf Spinczyk
>
>
>     Bin Du wrote:
>     > hi all,
>     > i have a question, haw can i call a c++ function in aspectc++
>     >
>     > -------------main.cc----------------------
>     >
>     > void func1 ( ) { ... };
>     > void func2 ( ) { ... };
>     > int main ( ) {
>     >                     func1 ( );
>     >                   //func2 ( );
>     > }
>     >
>     > -----------test.ah--------------------
>     >
>     > aspect test{
>     >  advice execution("% func1 (...) ") : before () {
>     >         func2 ( );
>     > };
>     >
>     > ac++ issues the error:
>     >                                  error: `func2' undeclared here
>     >
>     >
>     > ----------------------- main2.cc-----------------
>     >
>     > class Base1
>     > {
>     > public:
>     >    void ba1 ()
>     >     {
>     >      printf("Base2::b1 ()\n");
>     >     }
>     > }base1;
>     >
>     > class Base
>     > {
>     > public:
>     >
>     >     int b2 (inti)
>     >     {   inttemp = i;
>     >         return temp;
>     >     }
>     > } *a ;
>     >
>     > int main()
>     > {
>     >
>     >     a->b2(0);
>     >
>     >     //base1.b1(); same problem
>     >
>     >     return 0;
>     > }
>     >
>     > Thanks in advance,
>     > du bin
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > aspectc-user mailing list
>     > aspectc-user at aspectc.org <mailto:aspectc-user at aspectc.org>
>     > http://www.aspectc.org/mailman/listinfo/aspectc-user
>     >
>
>
>
>     ------------------------------
>
>     _______________________________________________
>     aspectc-user mailing list
>     aspectc-user at aspectc.org <mailto:aspectc-user at aspectc.org>
>     http://www.aspectc.org/mailman/listinfo/aspectc-user
>
>
>     End of aspectc-user Digest, Vol 2, Issue 1
>     ******************************************
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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