Skip to content

Commit 7dae5b0

Browse files
authored
use the same style of dll export/import definition and extern c as raylib, so it actually works on windows. (#115)
1 parent f5bd6c0 commit 7dae5b0

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/raygui.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,19 @@
137137
#endif
138138

139139
// Define functions scope to be used internally (static) or externally (extern) to the module including this file
140-
#if defined(RAYGUI_STATIC)
141-
#define RAYGUIDEF static // Functions just visible to module including this file
142-
#else
143-
#ifdef __cplusplus
144-
#define RAYGUIDEF extern "C" // Functions visible from other files (no name mangling of functions in C++)
145-
#else
146-
// NOTE: By default any function declared in a C file is extern
147-
#define RAYGUIDEF extern // Functions visible from other files
148-
#endif
149-
#endif
150-
151140
#if defined(_WIN32)
152-
#if defined(BUILD_LIBTYPE_SHARED)
153-
#define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll).
141+
// Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll
142+
#if !defined(BUILD_LIBTYPE_SHARED)
143+
#define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll)
154144
#elif defined(USE_LIBTYPE_SHARED)
155145
#define RAYGUIDEF __declspec(dllimport) // We are using raygui as a Win32 shared library (.dll)
146+
#else
147+
#define RAYGUIDEF // We are building or using raygui as a static library
156148
#endif
149+
#else
150+
#define RAYGUIDEF // We are building or using raygui as a static library (or Linux shared library)
157151
#endif
158152

159-
160153
#if !defined(RAYGUI_MALLOC) && !defined(RAYGUI_CALLOC) && !defined(RAYGUI_FREE)
161154
#include <stdlib.h> // Required for: malloc(), calloc(), free()
162155
#endif
@@ -181,6 +174,10 @@
181174

182175
#define TEXTEDIT_CURSOR_BLINK_FRAMES 20 // Text edit controls cursor blink timming
183176

177+
#if defined(__cplusplus)
178+
extern "C" { // Prevents name mangling of functions
179+
#endif
180+
184181
//----------------------------------------------------------------------------------
185182
// Types and Structures Definition
186183
// NOTE: Some types are required for RAYGUI_STANDALONE usage
@@ -3716,3 +3713,7 @@ static const char *CodepointToUtf8(int codepoint, int *byteLength)
37163713
#endif // RAYGUI_STANDALONE
37173714

37183715
#endif // RAYGUI_IMPLEMENTATION
3716+
3717+
#if defined(__cplusplus)
3718+
} // Prevents name mangling of functions
3719+
#endif

0 commit comments

Comments
 (0)