This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Porting from Solaris to Linux problem
- To: GCC help <gcc-help at gcc dot gnu dot org>
- Subject: Porting from Solaris to Linux problem
- From: Frank Geck <fgeck at att dot net>
- Date: Mon, 05 Nov 2001 11:30:25 -0500
- Organization: KeyWay Security
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()
{
...
}