From 29382a449282d17d3cbe8ed41569bffaf4df2973 Mon Sep 17 00:00:00 2001 From: FRex Date: Fri, 2 Jan 2015 02:12:52 +0100 Subject: [PATCH] Added checks for __cplusplus so that CSFML can be used in C++. --- include/SFML/Config.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/include/SFML/Config.h b/include/SFML/Config.h index 8c97c70..56b173b 100644 --- a/include/SFML/Config.h +++ b/include/SFML/Config.h @@ -33,6 +33,16 @@ #define CSFML_VERSION_MINOR 1 +//////////////////////////////////////////////////////////// +// Check if we need to mark functions as extern "C" +//////////////////////////////////////////////////////////// +#ifdef __cplusplus + #define CSFML_EXTERN_C extern "C" +#else + #define CSFML_EXTERN_C extern +#endif + + //////////////////////////////////////////////////////////// // Identify the operating system //////////////////////////////////////////////////////////// @@ -71,7 +81,7 @@ // Windows compilers need specific (and different) keywords for export and import #define CSFML_API_EXPORT extern "C" __declspec(dllexport) - #define CSFML_API_IMPORT extern __declspec(dllimport) + #define CSFML_API_IMPORT CSFML_EXTERN_C __declspec(dllimport) // For Visual C++ compilers, we also need to turn off this annoying C4251 warning #ifdef _MSC_VER @@ -87,13 +97,13 @@ // GCC 4 has special keywords for showing/hidding symbols, // the same keyword is used for both importing and exporting #define CSFML_API_EXPORT extern "C" __attribute__ ((__visibility__ ("default"))) - #define CSFML_API_IMPORT extern __attribute__ ((__visibility__ ("default"))) + #define CSFML_API_IMPORT CSFML_EXTERN_C __attribute__ ((__visibility__ ("default"))) #else // GCC < 4 has no mechanism to explicitely hide symbols, everything's exported #define CSFML_API_EXPORT extern "C" - #define CSFML_API_IMPORT extern + #define CSFML_API_IMPORT CSFML_EXTERN_C #endif