[aspectc-user] AspectC++ and Nokia/Trolltech Qt

Olaf Spinczyk os at aspectc.org
Tue Feb 1 18:15:22 CET 2011


Hi Alessandro,

see my answers below ...

Alessandro Bottoni wrote:
> I goggled around a little bit but I was unable to find any conclusive 
> information about the use of AspectC++ with Nokia Qt library...
>
> Is it possible to use AspectC++ with Qt?
Yes, it is possible, even though some of the Qt header files cause parse 
errors. At the moment 171 out of 220 standard examples from the Qt 4.7.0 
distribution can be compiled with ag++ without errors (latest version 
from the subversion repository). The remaining 49 examples are work in 
progress.

For experimenting with it, run qmake with "QMAKE_CXX=ag++ --Xcompiler" 
(including the quotes). Then the generated Makefile will call ag++ 
instead of g++ for compilation of all translation units. Please note 
that this simple integration approach does not handle file dependencies 
correctly. If you change any aspect header file, you need to recompile 
the whole project manually (make clean && make). If you know a good 
solution for this issue, please let me know. ;-)
>
> Qt uses its own reflection technology based on macros and a specific 
> pre-processor (MOC: Meta-Objects Compiler) that produces common C++ 
> code. Does this technology interfere with the AspectC++ mechanism?
Yes, this is indeed a bit problematic. Because ac++ cannot manipulate 
macro-generated code, several generated functions have to be excluded 
from your pointcut expressions as in the following example:

---
// these functions are created by moc and have macro-generated declarations
pointcut moc_gen() =
  "const QMetaObject & %::getStaticMetaObject()" ||
  "const QMetaObject * %::metaObject()" ||
  "void * %::qt_metacast(const char *)" ||
  "int %::qt_metacall(QMetaObject::Call, int, void **)";

aspect TestExecution {
  // advice for all but the generated functions
  advice execution("% ...::%(...)" && !moc_gen()) : before () {
    ...
  }
};
---


>
> And, last but not least: the most recent messages of this ML dates 
> back to July 2010, the last release of the library (1.0pre3) dates 
> back to 2006 and the last announcement on the AspectC++ wen sites 
> dates back to 2007.
>
> Is the AspectC++ project still alive?
Yes, we're alive! ;-)

Frankly speaking, I can understand that the project appears to be dead. 
I haven't had time to update the web site and roll out releases for too 
long. However, if you check the svn logs, you'll see that we've 
continuously improved the parser and the weaver. There were also some 
updates of the debian and ubuntu packages of AspectC++. Right now the 
project is gaining more speed.

>
> Is AspectC++ code still maintained and safe to use in real-world 
> projects?
Well, this is something nobody can promise. The code is maintained, but 
AspectC++ is an open source project and not an expensive commercial 
thing. It has to be used with care and some good will.

Best regards,

Olaf Spinczyk

PS: If you let me know which platform you are using, I will send you the 
latest binaries.




More information about the aspectc-user mailing list