I have some legacy code of InDesign Plugin that I am trying to compile for new version of InDesign that uses C++11 supported compiler with XCode.
There is a header file AdWrksSession.h
that contains a class object with C linkage as following. As declaration of an extern
object/variable goes:
extern "C" CAdWrksSession gAdWrksSession;
and the cpp file AdWrksSession.cpp
contains a global class object with Default constructor of the same name as the extern
object :
CAdWrksSession gAdWrksSession;
The older compilers were not showing any error message for this but when using it with new compiler provided by Apple for XCode 7.2.1 with C++11 support it shows me the following error:
Declaration of 'gAdWrksSession' in global scope conflicts with declaration with C language linkage
I have tried following already asked questions for C
linkage:
What is "extern linkage and with C language linkage"
Mixing declarations with extern, static and no storage specifier in global scope
I tried following syntaxes for extern variable declaration in header
file:
#ifdef __cplusplus
extern "C" {
#endif
CAdWrksSession gAdWrksSession;
#ifdef __cplusplus
}
#endif
and
#ifdef COMPILE_FOR_C_LINKAGE
extern "C" CAdWrksSession gAdWrksSession;
#else
extern "C++" CAdWrksSession gAdWrksSession;
#endif
but nothing has worked so far.
When I make the header
file declaration as static
the code builds successfully but the feature doesn't work, of course.
Can anyone help me here. Thanks.
Aucun commentaire:
Enregistrer un commentaire