This is the mail archive of the gcc-help@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]

Porting from Solaris to Linux problem


Well I have run into a little problem porting some code from Solaris to
Linux.  I think I know what the problem is and I can think of a lame way
to fix it but wanted to know what was the right way (maybe on Solaris I
had been doing it wrong all these years).  I have 2 files each
containing a function and a common header file with a global variable.
In each file I include the header file and mark the global as external.
In solaris this works fine using gcc, in Linux it gives me
multi-defined.  Any thought would be appreciated.

Exmple:

file: hdr.h
int i;

file: main.c
 #include "hdr.h"
extern int i;
main()
{
...
}

file: func2.c
 #include "hdr.h"
extern int i;
func2()
{
...
}



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