[aspectc-user] slices in separate header files
Olaf Spinczyk
Olaf.Spinczyk at informatik.uni-erlangen.de
Tue Nov 20 12:14:18 CET 2007
Hi,
have a look into the following example, which I posted on this list a
few days ago in order to explain how include cycles can be avoided:
http://p15111082.pureserver.info/pipermail/aspectc-user/attachments/20071117/8dc71e49/no_include_cycle-0001.pdf
For your concrete problem:
Just add the 'slice' keyword in front of 'class' in Slice.h, rename
Slice.h to Slice.ah, and remove 'class' from "slice class Slice" in
AnAspect.ah. Then it should work.
Best regards,
Olaf
Panu Bloigu wrote:
> Hello.
>
> The ac++ 1.0pre3 change log says that slices can be implemented in
> separate header files. What does that mean exactly and what's the
> correct syntax for defining a class slice outside of an aspect header?
>
> I have tried compiling the following files in Eclipse with the latest
> AspectC++ plugin.
>
> =======================================================
> // File: Slice.h
>
> #ifndef SLICE_H_
> #define SLICE_H_
>
> class Slice
> {
> public:
> Slice();
> virtual ~Slice();
> void method(){}
>
> //class Inner{};
> };
>
> #endif /*SLICE_H_*/
> =======================================================
>
> =======================================================
> // File: TargetClass.h
>
> #ifndef TARGETCLASS_H_
> #define TARGETCLASS_H_
> class TargetClass{};
> #endif /*TARGETCLASS_H_*/
> =======================================================
>
> =======================================================
> // File: AnAspect.ah
>
> #ifndef ANASPECT_AH_
> #define ANASPECT_AH_
> #include "Slice.h"
> aspect AnAspect
> {
> advice "TargetClass" : slice class Slice;
> };
> #endif /*ANASPECT_AH_*/
> =======================================================
>
> =======================================================
> // File: main.cpp
>
> #include "TargetClass.h"
> int main()
> {
> TargetClass tg;
> return 0;
> }
> =======================================================
>
>
> Now the complier produces the following output at the maximum
> verbosity level:
>
> =======================================================
> **** Build of configuration Debug for project Slices ****
>
> make -k all
> Building puma.config
> "/usr/lib/eclipse/plugins/org.aspectc.compiler.linux_0.9.93/AC/ag++"
> --gen_config -o "puma.config"
>
> Building file: ../main.cpp
> Invoking: GCC C++ Compiler
> "/usr/lib/eclipse/plugins/org.aspectc.compiler.linux_0.9.93/AC/ag++"
> -r repo.acp -p .. -I.. --c_compiler g++ -O0 -g3 -Wall
> -fmessage-length=0 -o"main.o" -c "../main.cpp" --Xweaver --keep_acc
> --keywords -v 9 && \
> echo -n main.d ./ > main.d && \
> g++ -MM -MG -P -w -include../AnAspect.ah -O0 -g3 -Wall -c
> -fmessage-length=0 "../main.cpp" >> main.d
> *
> *
> * AG++ Configuration:
> * Create puma.config: 1
> * Aspect C++ weaver:
> /usr/lib/eclipse/plugins/org.aspectc.compiler.linux_0.9.93/AC/ac++
> * C++ compiler: g++
> * Files: ../main.cpp
> * Options (G++): -I".." -O0 -g3 -Wall -fmessage-length=0 -c
> -I"../" -v
> * Options (AC++): -rrepo.acp -p".." -I".." --keywords -v9
> * Options (total): -rrepo.acp -p".." -I".." -O0 -g3 -Wall
> -fmessage-length=0 -c ../main.cpp -I"../" --keywords -v9 -v
> * Weave: 1 Compile: 1 Link: 0
> *
> *
> * Generating Puma configuration file
> - Parsing output of g++ compiler
> - Executing: "g++" -I".." -O0 -g3 -Wall -fmessage-length=0 -c
> -I"../" -v -E -dM -v -x c++ "/dev/null" 2>main.cpp.err.out
> 1>main.cpp.std.out
> - Exit: Success
> - removing temporary file: main.cpp.std.out
> - removing temporary file: main.cpp.err.out
> - Writing puma configuration file
> * Weaving
> error: Execution failed:
> "/usr/lib/eclipse/plugins/org.aspectc.compiler.linux_0.9.93/AC/ac++"
> --config "puma.config" -rrepo.acp -p".." -I".." --keywords -v9 -c
> "../main.cpp" -o "main.acc"
> make: *** [main.o] Error 1
> make: Target `all' not remade because of errors.
> - Executing:
> "/usr/lib/eclipse/plugins/org.aspectc.compiler.linux_0.9.93/AC/ac++"
> --config "puma.config" -rrepo.acp -p".." -I".." --keywords -v9 -c
> "../main.cpp" -o "main.acc"
> - Exitcode: 11 (should be 0 )
> Build complete for project Slices
> =======================================================
>
> As you can see there are no error messages printed, only this:
> "[main.o] error 1". Could someone please shed some light on this? How
> do go about defining slices in separate header files?
>
>
> Thanks,
>
> -- Panu.
>
>
> _______________________________________________
> 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