https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85580
Bug ID: 85580 Summary: "conflicting C language linkage declaration" warning for variables with identical names in `extern "C"` functions Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: freddie_chopin at op dot pl Target Milestone: --- Here's a minimal test case executed with 8.0.1-RC-20180427 (compiled for arm-none-eabi target, but I think the problem is not target-specific): -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- $ cat test.cpp extern "C" { void f1() { union some_type{ char a[2]; int b; } variable; } void f2() { union some_type{ char a[2]; int b; } variable; } } $ arm-none-eabi-gcc test.cpp -c test.cpp: In function 'void f2()': test.cpp:17:5: warning: conflicting C language linkage declaration 'f2()::some_type variable' } variable; ^~~~~~~~ test.cpp:9:5: note: previous declaration 'f1()::some_type variable' } variable; ^~~~~~~~ $ arm-none-eabi-gcc --version arm-none-eabi-gcc (bleeding-edge-toolchain) 8.0.1 20180427 (prerelease) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- For the problem to appear: - functions with the types and variables have to be extern "C" - the file must be C++ - there has to be both a type and a variable - the variables must have identical names The problem was spotted with ARM CMSIS headers, where similar pattern exists: https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/Core/Include/cmsis_gcc.h#L1929 Related discussion on mailing list: https://gcc.gnu.org/ml/gcc/2018-04/msg00191.html