Hello! I want to write a plugin that parse the AST. Could I get some hint about how to do it?
I have been reading this excellent article: http://codesynthesis.com/~boris/blog/2010/05/10/parsing-cxx-with-gcc-plugin-part-2/ The problem is that I fail to follow those advices. I fail to use 'global_namespace': daniel@daniel:~/gcc/build/gcc$ ./xgcc -fplugin=./myplugin2.so -c test1.c cc1: error: cannot load plugin ./myplugin2.so ./myplugin2.so: undefined symbol: global_namespace Here is the code: #include "gcc-plugin.h" #include "cp/cp-tree.h" #include <stdio.h> int plugin_is_GPL_compatible; static void traverse(tree ns) { } void override_gate(void *gcc_data, void *user_data) { printf("myplugin1:override_gate\n"); // Process AST traverse(global_namespace); } int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *version) { printf("myplugin1\n"); register_callback(plugin_info->base_name, PLUGIN_OVERRIDE_GATE, &override_gate, 0); return 0; } Best regards, Daniel Marjamäki