The following short program generates the mangled symbol "_Z3Foov" instead of the expected "Foo" when built with -DBUG. Without -DBUG and the "#pragma weak Random_Symbol" line, or if using g++ 3.2.3, the expected thing happens.
extern "C" { void Foo(); } #ifdef BUG #pragma weak Random_Symbol #endif void Foo() { } -- Summary: compiler loses extern "C" for function after #pragma weak Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: metcalf at lcs dot mit dot edu GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25999