This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Preprocessing in two or more C sources
- From: "Radu ION" <radu at racai dot ro>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 10 Jul 2002 20:01:00 +0300
- Subject: Preprocessing in two or more C sources
- Organization: RACAI
- Reply-to: "Radu ION" <radu at racai dot ro>
Hello
Problem : there are given 3 files : header.h, source1.c, source2.c. The
header is included in both source1.c and source2.c and contains some global
definitions of variabiles. After compilation, the linker complained that he
saw redefinitions.
So, the whole header.h is now enclosed by : #ifndef NAME #define NAME (on
separate lines) and #endif
The problem is still there. I can workaround this, but I don't understand.
My compile command was : gcc -Wall -ggdb source1.c source2.c -o runme
My logical assumption was that gcc should remember all the #define NAME
directives and behave accordingly on subsequent preprocessing on sources. It
appears that every source is preprocessed independently and so, the
preprocessing is done once per source file without state information being
exchanged (i.e. in source2.c NAME, should have already been defined) Is that
true ?
Does GNU Make know about this sort of problems ? I wonder if I can use make
to set up some 'project' enviroment like in MSVC++ for instance.
Thank you.
Radu