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]

Problems with GNU linker


Hi experts,

I tried to compile the program 'Test' consisting of files 'Include1.h',
'Source1.cpp' and 'Source2.cpp' with egcs1.1.1 on Unixware 7.1.0 (this
are simplified source files from the ACE/TAO distribution)

Include1.h
==========

#ifndef INCLUDE_1
#define INCLUDE_1
extern "C" {
        int ioctl(int a, int b, ...);
        static int ioctl(int a, int b, ...) {
                // Do something ...
                return 0;
        }
}
#endif


Source1.cpp
===========

#include "Include1.h"
int main() {
        int a = ioctl(4, 5);
        return a;
}


Source2.cpp
===========

#include "Include1.h"
int nosense(int b) {
        int a = 4;
        return ::ioctl(a, b);
}

gcc -o Test Source1.cpp Source2.cpp

The compiler does alright, but the linker complains: fatal error: symbol
'ioctl' multiply-defined.
This is confusing, because 'ioctl' should be seen only on file context
(defined statically). Moreover this test program compiles without linker
errors on native compilers on Unixware 2.0.3 and Unixware 7 and with
Visual C++ 6.0 compiler.

Can anybody help me? Thanks!

Engelbert Staller, Siemens AG Austria.


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