summaryrefslogtreecommitdiff
path: root/src/runtime/c/gu/defs.h
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2017-04-12 10:24:56 +0000
committerkrasimir <krasimir@chalmers.se>2017-04-12 10:24:56 +0000
commita8eaa2f2e560547e63c7976960435e1ae23a22b1 (patch)
tree06ce5fd0bc77a16113b5a53118843216fd3c1aea /src/runtime/c/gu/defs.h
parent915747efa793e53a7b7e9cfd861b4b4a46ace4a4 (diff)
a patch from Bjørnar Luteberget for compatibility with MSVC
Diffstat (limited to 'src/runtime/c/gu/defs.h')
-rw-r--r--src/runtime/c/gu/defs.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/runtime/c/gu/defs.h b/src/runtime/c/gu/defs.h
index 51a2293e3..f302481d6 100644
--- a/src/runtime/c/gu/defs.h
+++ b/src/runtime/c/gu/defs.h
@@ -25,6 +25,24 @@
#ifndef GU_DEFS_H_
#define GU_DEFS_H_
+// MSVC requires explicit export/import of
+// symbols in DLLs. CMake takes care of this
+// for functions, but not for data/variables.
+#if defined(_MSC_VER)
+#if defined(COMPILING_GU)
+#define GU_API_DATA_DECL __declspec(dllexport)
+#define GU_API_DATA __declspec(dllexport)
+#else
+#define GU_API_DATA_DECL __declspec(dllimport)
+#define GU_API_DATA ERROR_NOT_COMPILING_LIBGU
+#endif
+
+#else
+#define GU_API_DATA_DECL extern
+#define GU_API_DATA
+#endif
+// end MSVC workaround
+
#include <stddef.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -154,7 +172,7 @@ extern void* const gu_null;
// Dummy struct used for generic struct pointers
typedef struct GuStruct GuStruct;
-extern GuStruct* const gu_null_struct;
+GU_API_DATA_DECL GuStruct* const gu_null_struct;
typedef uintptr_t GuWord;