From 09f7a479f254f1de428e70df125543bb3ec516dc Mon Sep 17 00:00:00 2001 From: Ratstail91 Date: Sat, 25 Feb 2023 04:45:15 +1100 Subject: [PATCH] Box engine now builds without dll linkage issues --- Box.vcxproj | 4 ++-- Toy | 2 +- box/lib_runner.h | 31 +++++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Box.vcxproj b/Box.vcxproj index cc3e017..ecd740c 100644 --- a/Box.vcxproj +++ b/Box.vcxproj @@ -109,7 +109,7 @@ stdc17 - BOX_EXPORT;%(PreprocessorDefinitions) + BOX_EXPORT;LIB_RUNNER_EXPORT;%(PreprocessorDefinitions) $(SDL2Dir)\include;$(SDL2ImageDir)\include;%(SolutionDir)Toy\source;%(AdditionalIncludeDirectories) @@ -124,7 +124,7 @@ xcopy "$(SolutionDir)Toy\repl\repl_tools.*" "$(SolutionDir)box" /Y /I /E stdc17 - BOX_EXPORT;%(PreprocessorDefinitions) + BOX_EXPORT;LIB_RUNNER_EXPORT;%(PreprocessorDefinitions) $(SDL2Dir)\include;$(SDL2ImageDir)\include;%(SolutionDir)Toy\source;%(AdditionalIncludeDirectories) diff --git a/Toy b/Toy index 3aeddff..e9b347a 160000 --- a/Toy +++ b/Toy @@ -1 +1 @@ -Subproject commit 3aeddff736945f953bb7865678405091f06567ef +Subproject commit e9b347acb68914a05707f1388d18d645b0a18515 diff --git a/box/lib_runner.h b/box/lib_runner.h index bd26ac9..5c5b81c 100644 --- a/box/lib_runner.h +++ b/box/lib_runner.h @@ -5,12 +5,31 @@ int Toy_hookRunner(Toy_Interpreter* interpreter, Toy_Literal identifier, Toy_Literal alias); -//file system API - these need to be set by the host -TOY_API void Toy_initDriveDictionary(); -TOY_API void Toy_freeDriveDictionary(); -TOY_API Toy_LiteralDictionary* Toy_getDriveDictionary(); - #define TOY_OPAQUE_TAG_RUNNER 100 +//platform/compiler-specific instructions - because MSVC + Box Engine are dumber than a bag of rocks +#if defined(__linux__) || defined(__MINGW32__) || defined(__GNUC__) + +#define LIB_RUNNER_API extern + +#elif defined(_MSC_VER) + +#ifndef LIB_RUNNER_EXPORT +#define LIB_RUNNER_API __declspec(dllimport) +#else +#define LIB_RUNNER_API __declspec(dllexport) +#endif + +#else + +#define LIB_RUNNER_API extern + +#endif + +//file system API - these need to be set by the host +LIB_RUNNER_API void Toy_initDriveDictionary(); +LIB_RUNNER_API void Toy_freeDriveDictionary(); +LIB_RUNNER_API Toy_LiteralDictionary* Toy_getDriveDictionary(); + //file system API - for use with other libs -Toy_Literal Toy_getFilePathLiteral(Toy_Interpreter* interpreter, Toy_Literal* drivePathLiteral); +LIB_RUNNER_API Toy_Literal Toy_getFilePathLiteral(Toy_Interpreter* interpreter, Toy_Literal* drivePathLiteral);