[aspectc-user] Defining an Aspect Instantiation Model

Olaf Spinczyk Olaf.Spinczyk at informatik.uni-erlangen.de
Sun Aug 28 19:08:11 CEST 2005


Hello Sergio,

I'm sorry, my last answer was too short. The aspect code in your example 
has to look like this:

---
#ifndef MYASPECT_AH
#define MYASPECT_AH

#include <iostream>
//#include "myclass.h"

using namespace std;

aspect MyAspect {
        pointcut target() = "MyClass";

        advice target() : MyAspect myInstance;

public:
        static MyAspect *aspectof() {
                return tjp->target()->myInstance;
        }
};

#endif //MYASPECT_AH
---

You have to remove the #include "myclass.h". The reason is that you will 
otherwise have a cyclic dependency between myclass.h and myaspect.ah, 
because ac++ automatically generates a #include "myaspect.ah" in the 
target file of the introduction. This is done by ac++ to make sure that 
types, which are needed by the introduced code, will be known in the 
target header file.

If you change your code as described above, it will work properly with 
ac++ 0.9.2.

Best regards,

Olaf


Sergio Queiroz wrote:
>Olaf,
>
>I tried to compile my files again with AspectC++ 0.9.2 but did not work too  
>Any other idea about what is the problem?
>
>  
>>ag++ -o main main.cpp -Wall
>>    
>
>  
>>myclass.h:22: error: field `myInstance' has incomplete type
>>myaspect.ah:9: warning: all member functions in class `MyAspect' are private
>>error: Execution failed: "g++" -o "main" -xc++ "main.acc" -xnone -Wall
>>    
>
>Sérgio 
>
>---------- Original Message -----------
>From: Olaf Spinczyk <Olaf.Spinczyk at informatik.uni-erlangen.de>
>To: Sergio Queiroz <sergio at consiste.dimap.ufrn.br>
>Cc: aspectc-user at aspectc.org
>Sent: Fri, 19 Aug 2005 22:13:53 +0200
>Subject: Re: [aspectc-user] Defining an Aspect Instantiation Model
>
>  
>>Hi Sergio,
>>
>>your problem is the same as the one reported by Sylvain Meunier at 
>>the beginning of august on this mailing list. It is a bug in ac++ 
>>0.9.3 :-(. You can solve the problem by going back to version 0.9.2.
>>
>>The problem is already fixed in our internal development version. 
>>You can expect that your example code will also work with the next 
>>ac++ version, on which we are currently working urgently.
>>
>>Sorry for this problem,
>>
>>Olaf
>>
>>Sergio Queiroz wrote:
>>    
>>>Hi,
>>>
>>>I am trying to define an aspect in such way that every instance of a class has
>>>an different aspect instance associated.
>>>
>>>I tried to follow the examples in the AspectC++ - A Language Overview and in
>>>the AspectC++ Language Reference but they did not work :(
>>>
>>>When I try to compile my example with "ag++ -o main main.cpp -Wall" I get the
>>>following message:
>>>
>>>myaspect.ah:9: warning: all member functions in class `MyAspect' are private
>>>myclass.h:22: error: field `myInstance' has incomplete type
>>>error: Execution failed: "g++" -xc++ "main.acc" -xnone -Wall -o "main"
>>>
>>>So, the first line of the message is easy to avoid but I could not declare the
>>>variable myInstance.
>>>
>>>I am attaching my source code.
>>>
>>>Sérgio
>>> 
>>>------------------------------------------------------------------------
>>>
>>>#include "myclass.h"
>>>
>>>#include <iostream>
>>>
>>>using namespace std;
>>>
>>>int
>>>main() {
>>>	MyClass m1, m2;
>>>
>>>	m1.setM (8);
>>>
>>>	m2.setM (7);
>>>	
>>>	cout << m1.getM () << endl;
>>>
>>>	cout << m2.getM () << endl;
>>>	
>>>	return 0;
>>>}
>>> 
>>>------------------------------------------------------------------------
>>>
>>>#ifndef MYCLASS_H
>>>#define MYCLASS_H
>>>
>>>class MyClass {
>>>
>>>	public:
>>>
>>>	MyClass () {
>>>		m = 4;
>>>	}
>>>
>>>	int getM () {
>>>		return m;
>>>	}
>>>
>>>	void setM (int a) {
>>>		m = a;
>>>	}
>>>
>>>	private:
>>>		int m;
>>>};
>>>
>>>#endif // MYCLASS_H
>>> 
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>aspectc-user mailing list
>>>aspectc-user at aspectc.org
>>>http://www.aspectc.org/mailman/listinfo/aspectc-user
>>>
>>>      
>------- End of Original Message -------
>
>_______________________________________________
>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