[aspectc-user] RE: [aspectc-user] Defining structure inside advice code

Ferdinand Prantl ferdinand.prantl at ixos.de
Mon Jun 7 15:56:20 CEST 2004


Hi Bartosz,

this is a VC6 bug (classes/structures inside methods do not work), you can
try the new version, where it is already corrected (VC 2003 Toolkit is
free).

Ferda

> -----Original Message-----
> From: Bartosz Blimke [mailto:masb at chorwacja.com] 
> Sent: Monday, June 07, 2004 14:38
> To: aspectc-user at aspectc.org
> Subject: [aspectc-user] Defining structure inside advice code
> 
> Hi,
> 
> C++ doesn't allow to have nested definition of functions,
> thats mean it will not allow to make definition like this.
> 
> 
> int func1()
> {
>  int func2()
>  {
>    return 5;
>  }
> 
>  return func2();
> }
> 
> Simple solution for this problem is to pack the nested 
> function into structure
> 
> int func1()
> {
>  struct aa
>  {
>    int func2()
>    {
>      return 5;
>    }
>  } simpleStructInstance;
> 
>  return simpleStructInstance.func2();
> }
> 
> C++ compiler compiles it without problems.
> 
> Problem is with ac++ advice code:
> 
> //main.cpp
> #include <stdio.h>
> 
> 
> void func () {
> 
>    printf ("func\n");
> }
> 
> 
> int main (int argc, char * argv[]) {
>    func ();
>    return 0;
> }
> //end of main.cpp
> 
> aspect Aspect {
> 
>     pointcut methods() = execution("% func()");
> 
> 
>     advice methods() : before()
>     {
>       struct simpleStruct{
> 	int methodOfStruct()
>         {
> 	  return 0;
> 	}
>       } instance;
> 
>       instance.methodOfStruct();
>     }
> 
> };
> 
> Linking...
> main.obj : error LNK2005: "public: int __thiscall `public: 
> void __thiscall 
> Aspect::__a0_before(void)'::`2'::simpleStruct::methodOfStruct(void)"
> (?methodOfStruct at simpleStruct@?1??__a0_before at Aspect@@QAEXXZ at QAEHXZ)
> already defined in TestAspectProject_LinkOnce.obj 
> Debug\TestAspectProject.exe : fatal error LNK1169: one or 
> more multiply defined symbols found
> 
> 
> The same problem is with after().
> When I use around() problem is only if I use tjp->proceed() 
> inside the body of advice code.
> 
> If the structure is defined inside aspect body but outside 
> the advice body problem dissapear.
> 
> Is it another problem linked to vc++ compiler, or ac++ bug ?
> 
> 
> Greets,
> 
> Bartosz Blimke
> 
> 
> 
> 
> 
> _______________________________________________
> 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