multiple defintions error

Atif Shahab
Mon Sep 25 01:09:00 GMT 2000


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

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

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

More information about the Gcc mailing list