简体   繁体   中英

ANSI C library for Aspect-Oriented Programming

I'm searching for a good ANSI C library for Aspect-Oriented Programming.

Some desired features are:

  • Accessing and modifying arguments of the target function.
  • Making the target function return and controlling the return value.

I found aspeCt C ( https://sites.google.com/a/gapp.msrg.utoronto.ca/aspectc/home ), reading the documentation it seems to have everything I need, but when, following the instructions, I run make to compile and pass the tests, the tests fail.

There is any alternative?

You can try AspectC++ is a project that extends the AspectJ approach to C/C++.

For example if you want to a simple C program using Aspect:

int main() {
    printf("world");

}

And then you will have an aspect.cc

before(): execution(int main()) {
    printf("Hello ");
}

after(): execution(int main()) {
    printf(" from AspectC ! \n");
}

You compile both with > acc hello.ac world.mc

And the result is:

gcc hello.c world.c
>./a.out
 Hello world from AspectC !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM