所以在网上搜索了一段时间后,我决定在这里尝试一下,因为它似乎是一个很好的讨论论坛。我试图创建一个简单的 gcc 插件。程序代码附在这封邮件的末尾,但用简单的英语它注册插件并确保在注册 pragma 时调用 pragma_init 函数。正是在这里,我使用 c_register_pragma 来截取一些 pragma。
我使用http://gcc.gnu.org/onlinedocs/gccint/Plugins-building.html#Plugins-building中的示例对其进行编译。编译和链接工作正常。但是,当我加载插件时,我得到:
gcc -c -fplugin=plugin.so test.c -o test.o
cc1: error: cannot load plugin plugin.so
plugin.so: undefined symbol: warning
我究竟做错了什么?此外,当包含一些头文件(稍后将需要)时,我得到了很多错误。例如,包括“tree.h”会产生(在 50 个其他错误中):
/machmode.h:262:1: error: unknown type name 'class'
class bit_field_mode_iterator
^
/machmode.h:263:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
{
^
/plugin/include/tree.h:27:0,
from conftest.c:63:
/vec.h:220:8: error: field 'register_overhead' declared as a function
有人知道我做错了什么吗?
谢谢