From 3db2d60a4de9865f4ecd1e857dbf6c55a72169fd Mon Sep 17 00:00:00 2001 From: "Marco Antonio J. Costa" Date: Wed, 22 Jul 2026 11:23:41 -0300 Subject: [PATCH] drop the extern "C" wrapper whose other half is commented out DEBUG.H once wrapped its declarations in extern "C", and DEBUG.cpp wrapped the matching definitions to agree. At some point the header's pair was commented out, both the opening brace and the closing one: /* #ifdef __cplusplus extern "C" { #endif */ That had to happen, because the block would otherwise have swallowed , and namespace sgp further down the header. The wrapper in DEBUG.cpp was left behind, so seven variables are declared with C++ linkage in the header and defined with C linkage in the source. That is ill-formed. MSVC takes the linkage of the first declaration it sees, which is the header's, so the mangled names still agree and the tree still links; clang refuses. The header is the only place these seven are declared, so removing the wrapper leaves everything with the C++ linkage it already had. Nothing here needs to be callable from C. A second such wrapper remains further down the file, inside #ifdef SGP_DEBUG. Nothing in the build defines SGP_DEBUG and nothing it contains is declared in a header, so it is neither compiled nor mismatched, and it is left alone. Verification: ninja -C build parse # language-linkage class gone: 60 -> 55 sites ninja -C build -k 0 # Release, four applications, green ninja -C build-debug -k 0 # Debug, four applications, green The seven diagnostics sit on five lines, three of them sharing a single declaration, and the parse target counts one site per line. Co-Authored-By: Claude Opus 4.8 --- sgp/DEBUG.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/sgp/DEBUG.cpp b/sgp/DEBUG.cpp index c73062454..ca26d3a94 100644 --- a/sgp/DEBUG.cpp +++ b/sgp/DEBUG.cpp @@ -49,10 +49,6 @@ #include "debug_util.h" -#ifdef __cplusplus -extern "C" { -#endif - BOOLEAN gfRecordToFile = FALSE; BOOLEAN gfRecordToDebugger = TRUE; @@ -70,16 +66,8 @@ CHAR8 gubAssertString[512]; CHAR8 gbTmpDebugString[8][MAX_MSG_LENGTH2]; UINT8 gubStringIndex = 0; -#ifdef __cplusplus -} -#endif - #ifdef SGP_DEBUG -#ifdef __cplusplus -extern "C" { -#endif - //************************************************************************** // // Defines @@ -106,10 +94,6 @@ void RemoveDebugText( void ); STRING512 debugLogFileName; FILE * debugLogFile = 0; -#ifdef __cplusplus -} -#endif - //************************************************************************** // // Functions