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
<stdexcept>, <list> 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 <noreply@anthropic.com>
This commit is contained in:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
co-authored by Claude Opus 4.8
parent e56a372871
commit 3db2d60a4d
-16
View File
@@ -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