From dfff838afa37fd89459cfcae82d2e26feeea0fd2 Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Sun, 2 Nov 2014 16:28:37 +0200 Subject: [PATCH] Use "extern" even for local decls, C++ quick fix See GH-63. --- src/duk_features.h.in | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/duk_features.h.in b/src/duk_features.h.in index a66dbd8c..93595589 100644 --- a/src/duk_features.h.in +++ b/src/duk_features.h.in @@ -1983,6 +1983,24 @@ typedef FILE duk_file; #define DUK_LOCAL_DECL static #define DUK_LOCAL static +/* In C++ one cannot declare and define "static" variables separately (GH-63). + * As a quick workaround, use "extern" instead: it makes the symbol table ugly + * but allows compilation. A better fix is to avoid the need to forward declare + * internal symbols, but it requires changes to combine_src.py. + * + * XXX: better fix is needed. + */ +#if defined(DUK_F_CPP) +#undef DUK_INTERNAL_DECL +#undef DUK_INTERNAL +#undef DUK_LOCAL_DECL +#undef DUK_LOCAL +#define DUK_INTERNAL_DECL extern +#define DUK_INTERNAL /*empty*/ +#define DUK_LOCAL_DECL extern +#define DUK_LOCAL /*empty*/ +#endif + /* * __FILE__, __LINE__, __func__ are wrapped. Especially __func__ is a * problem because it is not available even in some compilers which try