[aspectc-user] multiple definition errors for "global" variables

Hans VB hans.vanbroeckhoven at telenet.be
Wed Feb 2 16:05:19 CET 2005


Hello,

I'm writing a logging aspect which logs to a textfile.
Therefore in my .ah-file I have to define :

ofstream logfile("test.log");

For convenience I define this 'global' in the aspect (i.e. before the 
definition of the aspect LoggingAspect { ... }; )
This works fine when the advice code only needs to be triggered from one 
.cpp-file. When I need advice for code scattered across multiple 
.cpp-files (multiple classes) everything weaves fine, but during linking 
i get an error from g++ :

multiple definition of _logfile

I don't think this is intended behaviour ?


I managed to work around this by using
ofstream logfile("test.log",ios::app);
in every piece of advice-code.

Greets,
Hans




More information about the aspectc-user mailing list