From 7dae5b06f7c54ba9ed47cc1d8e852f975da2ec3a Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Sat, 26 Dec 2020 10:27:50 -0800 Subject: [PATCH] use the same style of dll export/import definition and extern c as raylib, so it actually works on windows. (#115) --- src/raygui.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index 384b09a..fbe493c 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -137,26 +137,19 @@ #endif // Define functions scope to be used internally (static) or externally (extern) to the module including this file -#if defined(RAYGUI_STATIC) - #define RAYGUIDEF static // Functions just visible to module including this file -#else - #ifdef __cplusplus - #define RAYGUIDEF extern "C" // Functions visible from other files (no name mangling of functions in C++) - #else - // NOTE: By default any function declared in a C file is extern - #define RAYGUIDEF extern // Functions visible from other files - #endif -#endif - #if defined(_WIN32) - #if defined(BUILD_LIBTYPE_SHARED) - #define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll). + // Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll + #if !defined(BUILD_LIBTYPE_SHARED) + #define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll) #elif defined(USE_LIBTYPE_SHARED) #define RAYGUIDEF __declspec(dllimport) // We are using raygui as a Win32 shared library (.dll) + #else + #define RAYGUIDEF // We are building or using raygui as a static library #endif +#else + #define RAYGUIDEF // We are building or using raygui as a static library (or Linux shared library) #endif - #if !defined(RAYGUI_MALLOC) && !defined(RAYGUI_CALLOC) && !defined(RAYGUI_FREE) #include // Required for: malloc(), calloc(), free() #endif @@ -181,6 +174,10 @@ #define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming +#if defined(__cplusplus) +extern "C" { // Prevents name mangling of functions +#endif + //---------------------------------------------------------------------------------- // Types and Structures Definition // NOTE: Some types are required for RAYGUI_STANDALONE usage @@ -3716,3 +3713,7 @@ static const char *CodepointToUtf8(int codepoint, int *byteLength) #endif // RAYGUI_STANDALONE #endif // RAYGUI_IMPLEMENTATION + +#if defined(__cplusplus) +} // Prevents name mangling of functions +#endif \ No newline at end of file