[aspectc-user] Re: Problems using AspectC++ with SystemC

Matthias Urban matthias.urban at pure-systems.com
Sun Feb 20 18:57:34 CET 2005


Hi Sergio,

> I made a small example where we can see the errors and I am sending the source
> files.

Ok, now I've found the problem. It's furtunately no problem of ac++ but 
a bug in ag++. When doing the final link of the application the 
following command is invoked:

ag++ -ggdb -O3 -Wall -Wno-deprecated -p. --config puma.config -v9 -I
. -I$SYSTEMC/include -L. -L$SYSTEMC/lib-linux -o test.x test.o main.o 
-lsystemc -lm  2>&1 | c++filt

ag++ should then execute the following command:

g++ -o "test.x" -ggdb -O3 -Wall -Wno-deprecated -v  -I. 
-I$SYSTEMC/include -L. -L$SYSTEMC/lib-linux "test.o" "main.o" -x c++ 
-lsystemc -lm

But instead the following command is executed:

g++ -o "test.x" -ggdb -O3 -Wall -Wno-deprecated -v  -I. 
-I$SYSTEMC/include -L. -L$SYSTEMC/lib-linux -lsystemc -lm "test.o" 
"main.o" -x c++

As you can see the -lsystemc and -lm options are on the wrong position 
causing the linking to fail. Unfortunately I couldn't discover a way to 
convince ag++ to put the -l options at the end of the command line. This 
isn't nice but no real problem, simply use g++ directly when linking the 
application. Nevertheless, compiling the source files using ag++ works 
well.

> The files did not compile with the declaration of SC_EXTERNS_H so I commented
> this line.

You are right, don't know why it worked for my first test application. 
The correct quick fix would be to insert the declaration

extern "C" int sc_main(int argc, char* argv[]);

at the beginning of every .cpp file including a systemc header. But as 
long as you don't intend to apply advice to sc_main(), you don't have to 
bother about it.

Hope this helps. This are major bugs to be fixed very soon ;-).

By the way, you should always put guarding #ifndefs around your aspect 
declarations since ac++ handles aspect header files like any other 
header files. Especially aspect declarations may be inlined several 
times into the same translation unit! Not protected by an #ifndef may 
cause redefinition errors.

Best regards,
Matthias

-- 
Matthias Urban                          Phone: +49-391-544569-32
pure-systems GmbH                       Fax:   +49-391-544569-90



More information about the aspectc-user mailing list