[aspectc-user] Re: [aspectc-user] How to introduce a method into a class ??
Bartosz Blimke
masb at chorwacja.com
Thu Jul 29 14:16:56 CEST 2004
> Thank you for you answer,
>
> Now I am able to weave before/around/after advice into
> my method calls/executions and introduce new
> fields/methods into my classes.
>
> I can see the result in the resulting file (ac.out by
> default) generated by ac++.
>
> BUT I have a problem when compiling (with ac++) this
> file (ac.out that I rename test.cc) in the case where
> I have introduced a method. I get the following error
> :
>
> test.ah:11: redefinition of `class TEST'
> test.ah:11: previous definition here
>
> In the case where i have introduced before/after
> advice, the file compiles and links seamlessly to the
> rest of my application.
>
> I don't know if someone else has already encountered
> such a problem and managed to solve it.
>
> My aspect (test.ah) is the following :
>
> #include<stdio.h>
>
> aspect TEST {
>
> public:
>
> advice "Class1" :
> void do_some_work() {
> printf("doing some work\n");
> }
> };
>
> And the resulting file in the generated ac.out has the
> following code :
>
> class Class1 {
>
> public:
>
> // original methods
>
> public:
> void do_some_work() {
> printf("doing some work\n");
> }
>
> // other code
>
> Thanks.
>
Try to add preprocessor definitions to the file,
to not let them to be included more than once.
This should help.
for example example:
#ifndef _TEST_AH_
#define _TEST_AH_
#include<stdio.h>
aspect TEST {
public:
advice "Class1" :
void do_some_work() {
printf("doing some work\n");
}
};
#endif //_TEST_AH_
More information about the aspectc-user
mailing list