header file duplicate definitions advice sought
Stuart Cracraft
cracraft at pogo.ai.mit.edu
Fri Mar 8 12:41:34 AEST 1991
Hello!
I am wondering if someone can help me with a problem I'm trying to resolve.
How can you eliminate redefined errors in C when you have several thousand
"#define"'s defined in both *.h and *.c files(about 2000 files combined)?
Where *.h and *.c files are scattered around in different directories.
So far I have only collected very few possible ideas to the problem.
One of them is to have "#ifndef" statements over places that I am getting
redefined errors. However, this is not a good solution because this
will not work on case such as below:
==========================================================================
inside abc.h inside def.h
#define a 4 #define a 5
inside ghi.c
#include <abc.h>
#include <def.h>
Which value is ghi.c referring to, 4 or 5?
Thus, I would end up searching in ghi.c to see which is a appropriate value
and I might have to do this million times manually for other similar cases.
Another idea is to list all the redefined symbols(using a script to
retrieve) in following ways:
header file
symbol is
symbol value located files including header files
------ ----- ----------- ----------------------------
a 5 abc.h def.h
xyz.h
kuy.c
a 3 kby.h ubc.h
ppp.h
etc...
This gives me more of general info which I might use it in changing the
symbol name in the header file and also in files where header file
is included. And I think this is a very clean solution except that
again there are too many symbols(approximately 7000 of them) and I
would end up spending million years.
I have couple more ideas like above but they are not a good approach.
Actually, I don't think there are any good simple way of resolving
the problem but I am asking if anyone out there has/had similar
experience to share with me how you have dealt with the problem.
Thank you (sorry my question got little too lengthy :)
More information about the Comp.unix.questions
mailing list