Merge pull request #51 from FRex/master

Added extern "C" inside ifdef __cplusplus to allow including and linking CSFML correctly in C++.
This commit is contained in:
Laurent Gomila committed 2015-01-02 17:23:54 +01:00
commit 2a2951e608
1 file changed
+13 -3
+13 -3
View File
@@ -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