multiple defintions error

Atif Shahab atif@viewinternet.com.sg
Mon Sep 25 01:09:00 GMT 2000


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
******************************************************



More information about the Gcc mailing list