From 49f8bb2d42c970325160658862b0a7f0e2cd066a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 4 Nov 2013 10:02:58 +0000 Subject: Put extern "C" guards around all stub table struct definitions, so it is usable for C++ compilers as well without the danger of modifying the calling convention. For tclDecls.h it was no problem, because tcl.h already contains those guards. But for the other *Decls.h files (e.g. tclTomMathDecls.h) it was not correct. --- generic/tclDecls.h | 8 +++++--- generic/tclIntDecls.h | 8 +++++--- generic/tclIntPlatDecls.h | 8 +++++--- generic/tclPlatDecls.h | 8 +++++--- generic/tclTomMathDecls.h | 8 +++++--- tools/genStubs.tcl | 5 +++-- 6 files changed, 28 insertions(+), 17 deletions(-) diff --git a/generic/tclDecls.h b/generic/tclDecls.h index 4ca9f68..b11c0d8 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -31,6 +31,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -4131,10 +4135,8 @@ typedef struct TclStubs { void (*tclUnusedStubEntry) (void); /* 630 */ } TclStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TclStubs *tclStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tclIntDecls.h b/generic/tclIntDecls.h index 1dc797a..e4e85ad 100644 --- a/generic/tclIntDecls.h +++ b/generic/tclIntDecls.h @@ -50,6 +50,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -1309,10 +1313,8 @@ typedef struct TclIntStubs { char * (*tclDoubleDigits) (double dv, int ndigits, int flags, int *decpt, int *signum, char **endPtr); /* 249 */ } TclIntStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TclIntStubs *tclIntStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tclIntPlatDecls.h b/generic/tclIntPlatDecls.h index 1e68c9c..80dd2ad 100644 --- a/generic/tclIntPlatDecls.h +++ b/generic/tclIntPlatDecls.h @@ -37,6 +37,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -533,10 +537,8 @@ typedef struct TclIntPlatStubs { #endif /* MACOSX */ } TclIntPlatStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TclIntPlatStubs *tclIntPlatStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tclPlatDecls.h b/generic/tclPlatDecls.h index 8652e8d..ef23c84 100644 --- a/generic/tclPlatDecls.h +++ b/generic/tclPlatDecls.h @@ -36,6 +36,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -87,10 +91,8 @@ typedef struct TclPlatStubs { #endif /* MACOSX */ } TclPlatStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TclPlatStubs *tclPlatStubsPtr; + #ifdef __cplusplus } #endif diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h index 04a23f3..056ad85 100644 --- a/generic/tclTomMathDecls.h +++ b/generic/tclTomMathDecls.h @@ -134,6 +134,10 @@ /* !BEGIN!: Do not edit below this line. */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Exported function declarations: */ @@ -538,10 +542,8 @@ typedef struct TclTomMathStubs { int (*tclBN_mp_cnt_lsb) (mp_int *a); /* 63 */ } TclTomMathStubs; -#ifdef __cplusplus -extern "C" { -#endif extern TclTomMathStubs *tclTomMathStubsPtr; + #ifdef __cplusplus } #endif diff --git a/tools/genStubs.tcl b/tools/genStubs.tcl index c7dbe93..37205b2 100644 --- a/tools/genStubs.tcl +++ b/tools/genStubs.tcl @@ -991,6 +991,8 @@ proc genStubs::emitHeader {name} { append text "#define ${CAPName}_STUBS_REVISION $revision\n" } + append text "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n" + emitDeclarations $name text if {[info exists hooks($name)]} { @@ -1014,8 +1016,7 @@ proc genStubs::emitHeader {name} { append text "} ${capName}Stubs;\n\n" - append text "#ifdef __cplusplus\nextern \"C\" {\n#endif\n" - append text "extern ${capName}Stubs *${name}StubsPtr;\n" + append text "extern ${capName}Stubs *${name}StubsPtr;\n\n" append text "#ifdef __cplusplus\n}\n#endif\n" emitMacros $name text -- cgit v0.12