Outlined below is a problem I ran into today followed by a suggested fix. First, some background information. XSUB.h in 5.8.8. defined the macro XS(name) as such: ===== START CODE ===== #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) # define XS(name) __declspec(dllexport) void name(pTHX_ CV* cv) #else # ifdef HASATTRIBUTE_UNUSED # define XS(name) void name(pTHX_ CV* cv __attribute__unused__) # else # define XS(name) void name(pTHX_ CV* cv) # endif #endif ===== END CODE ===== The main version of the definition I'm interested is "#define XS(name) void name(pTHX_ CV* cv)". In 5.10.0 these definitions changed to the following: ===== START CODE ===== /* XSPROTO() is also used by SWIG like this: * * typedef XSPROTO(SwigPerlWrapper); * typedef SwigPerlWrapper *SwigPerlWrapperPtr; * * This code needs to be compilable under both C and C++. * * Don't forget to change the __attribute__unused__ version of XS() * below too if you change XSPROTO() here. */ #define XSPROTO(name) void name(pTHX_ CV* cv) #undef XS #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) # define XS(name) __declspec(dllexport) XSPROTO(name) #endif #if defined(__SYMBIAN32__) # define XS(name) EXPORT_C XSPROTO(name) #endif #ifndef XS # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) # define XS(name) void name(pTHX_ CV* cv __attribute__unused__) # else # ifdef __cplusplus # define XS(name) extern "C" XSPROTO(name) # else # define XS(name) XSPROTO(name) # endif # endif #endif ===== END CODE ===== The main definition I'm interested here is the __cplusplus specific one: "#define XS(name) extern "C" XSPROTO(name)". == THE PROBLEM == I have some code (namely XML::Xerces-2.7.0-0's Xerces.cpp source file) which does one of these: *code*: typedef XS(SwigPerlWrapper); Now, on 5.8.8 this would evaluate to something the following statement, which is all well and good: *code*: typedef void SwigPerlWrapper(pTHX_ CV* cv); However, on 5.10.0 it evaluates to: *code*: typedef extern "C" void SwigPerlWrapper(pTHX_ CV* cv); The "extern "C"" part makes the compiler die with the following message: error: expected unqualified-id before string constant error: expected `,' or `;' before string constant == PROPOSED FIX == I propose that there be a new macro added called XS_TYPEDEF. This macro would be defined in the usual way when __cplusplus is not present: #define XS_TYPEDEF(name) typedef XS(name) However, when __cplusplus is defined it would be set to something like this: #define XS_TYPEDEF(name) extern "C" { typedef XS(name); } What do you guys think? -PatrickThread Next