This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
General search for symbols...
- From: Stephen Biggs <xyzzy at hotpop dot com>
- To: GCC list <gcc at gcc dot gnu dot org>
- Date: 02 Apr 2003 15:09:08 -0200
- Subject: General search for symbols...
I am trying to port GCC to another machine.
Given that I have a file <new gcc
path>/gcc/config/<machine>/<machine>.c, how would I, within any of the
functions in that file find out if a certain symbol has been defined by
a "#define" statement in the C source that is being compiled?
E.g., the source file consists of one line:
#define DEFINED_CONSTANT_2
Note: my call to print_node CRASHES the compiler.
I have tried various versions of:
if((decl = getdecls()))
print_node(stderr,"tree: ",decl,4); /* this CRASHES!!! */
for ( ; decl; decl = TREE_CHAIN (decl))
{
if (TREE_CODE (decl) == IDENTIFIER_NODE)
{
if(!strcmp(IDENTIFIER_POINTER(decl),"DEFINED_CONSTANT_1"))
fprintf(stderr,"DEFINED_CONSTANT_1" found, code
%d\n",TREE_CODE(decl));
else if(!strcmp(IDENTIFIER_POINTER(decl),"DEFINED_CONSTANT_2"))
fprintf(stderr,"DEFINED_CONSTANT_2 found, code
%d\n",TREE_CODE(decl));
}
}