简体   繁体   English

用于面向方面编程的ANSI C库

[英]ANSI C library for Aspect-Oriented Programming

I'm searching for a good ANSI C library for Aspect-Oriented Programming. 我正在为面向方面编程寻找一个好的ANSI C库。

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. 我找到了aspeCt C( https://sites.google.com/a/gapp.msrg.utoronto.ca/aspectc/home ),阅读文档似乎有我需要的一切,但是当按照说明操作时,我运行make编译并传递测试,测试失败。

There is any alternative? 有什么选择吗?

You can try AspectC++ is a project that extends the AspectJ approach to C/C++. 您可以尝试AspectC ++是一个将AspectJ方法扩展到C / C ++的项目。

For example if you want to a simple C program using Aspect: 例如,如果你想使用Aspect的简单C程序:

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

}

And then you will have an aspect.cc 然后你将有一个方面.c

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

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

You compile both with > acc hello.ac world.mc 您可以使用> acc hello.ac world.mc编译它们

And the result is: 结果是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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