From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21917 invoked by alias); 21 Jan 2013 15:05:22 -0000 Received: (qmail 21751 invoked by uid 48); 21 Jan 2013 15:04:48 -0000 From: "solomon.gibbs.lists at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56066] New: g++ generates strong symbols conflicting with C99 extern inline code on Windows Date: Mon, 21 Jan 2013 15:05:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: solomon.gibbs.lists at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg01972.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56066 Bug #: 56066 Summary: g++ generates strong symbols conflicting with C99 extern inline code on Windows Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: solomon.gibbs.lists@gmail.com Created attachment 29236 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29236 Header file, C99 and C++ file that create conflict When a C99 translation unit containing extern inline functions is linked with a C++ translation unit using those same inlines, g++ generates an additional symbol for the inline function in the C++ TU. Linking causes a multiple definitions error. I am informed that this is a likely a problem with PE/COFF and that under ELF, the g++ generated symbols would be marked weak and eliminated at link time. For example, when buffer.h as shown below is included by C99 and C++ TUs, the error occurs. (Complete files are attached) // buffer.h inline bool has_remaining(void* obj) { ... } // buffer.c extern inline bool has_remaining(void* obj); // app.cpp int main(...) { has_remaining("okay"); ... } // compile $ gcc -std=gnu99 -o buffer.o -c --save-temps buffer.c $ g++ -std=gnu++11 -o app.o -c --save-temps app.cpp $ g++ -Wl,--subsystem,console -o app.exe app.o buffer.o buffer.o:buffer.c:(.text+0x0): multiple definition of `has_remaining' app.o:app.cpp:(.text$has_remaining[_has_remaining]+0x0): first defined here collect2.exe: error: ld returned 1 exit status $ gcc -v Using built-in specs. COLLECT_GCC=C:\opt\MinGW\bin\gcc.exe COLLECT_LTO_WRAPPER=c:/opt/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.7.2 (GCC) $ g++ -v Using built-in specs. COLLECT_GCC=C:\opt\MinGW\bin\g++.exe COLLECT_LTO_WRAPPER=c:/opt/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.7.2 (GCC) $ ld -v GNU ld (GNU Binutils) 2.22