Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ANSI C library for Aspect-Oriented Programming

Tags:

c

aop

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?

like image 763
FerCa Avatar asked Nov 30 '25 14:11

FerCa


1 Answers

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 !
like image 93
Tomás Avatar answered Dec 03 '25 11:12

Tomás



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!