This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

multiple defintions error



Hi,

sorry if this has already been asked before but I'm having a problem with
the header files inclusion.

I have three header files and 2 source files

a.h
b.h
c.h

b.c
c.c

a.h contains some general inline funtions that I would like to be use
in b.c and c.c.  However when I do that the linker complains of multiple
defintions.

I tried defining a macro __a_h, __b_h & __c_h in each respective header
file but it seems that that doesn't help.  Still 2 copies of a.h are
included.

I can successfully compile the source code if I manually user -D option
and define the __a_h when creating the second object file, meaning

gcc -c b.c //first object file.

gcc -c c.c -D __a_h //second object file.

Now when I link the two object files linker is happy since only one copy
of the header file a.h has been included.

Is there a neater way of doing this?

Thanks in advance.

-- 
Atif Shahab

******************************************************
Check your email from anywhere using www.viewemail.com
******************************************************


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]