diff --git a/CMakeLists.txt b/CMakeLists.txt index 51dedff..71419ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,13 @@ cmake_minimum_required(VERSION 2.8) project(chaiscript) -option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" TRUE) +# MINGW does not yet support C++11's concurrency features +if (MINGW) + option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" FALSE) +else() + option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" TRUE) +endif() + option(BUILD_MODULES "Build Extra Modules (stl, reflection)" TRUE) option(BUILD_SAMPLES "Build Samples Folder" FALSE) @@ -39,7 +45,9 @@ include(CPack) include(cmake/CheckCXX11Features.cmake) -find_library(READLINE_LIBRARY NAMES readline PATH /usr/lib /usr/local/lib /opt/local/lib) +if(NOT MINGW) + find_library(READLINE_LIBRARY NAMES readline PATH /usr/lib /usr/local/lib /opt/local/lib) +endif() if(HAS_CXX11_VARIADIC_TEMPLATES) message(STATUS "Variadic Template support detected") @@ -68,7 +76,7 @@ if(MSVC) endif() else() add_definitions(-Wall -Wextra -Wshadow -pedantic -std=c++0x) - + if (APPLE) add_definitions(-Wno-sign-compare) endif() @@ -88,6 +96,12 @@ else() set (EXTRA_LINKER_FLAGS ) endif() +# limitations in MinGW require us to make an optimized build +# for the sake of object sizes or something +if (MINGW) + add_definitions(-O3) +endif() + include_directories(include) diff --git a/samples/example.cpp b/samples/example.cpp index e753451..bc8c982 100644 --- a/samples/example.cpp +++ b/samples/example.cpp @@ -5,6 +5,7 @@ // http://www.chaiscript.com #include +#include #include #include diff --git a/src/main.cpp b/src/main.cpp index bd80f21..6a8e3a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,16 +15,20 @@ #include #include #else + +char *mystrdup (const char *s) { + char *d = static_cast(malloc (strlen (s) + 1)); // Space for length plus nul + if (d == nullptr) return nullptr; // No memory + strcpy (d,s); // Copy the characters + return d; // Return the new string +} + char* readline(const char* p) { std::string retval; std::cout << p ; std::getline(std::cin, retval); -#ifdef CHAISCRIPT_MSVC - return std::cin.eof() ? NULL : _strdup(retval.c_str()); -#else - return std::cin.eof() ? NULL : strdup(retval.c_str()); -#endif + return std::cin.eof() ? NULL : mystrdup(retval.c_str()); } void add_history(const char*){} void using_history(){} diff --git a/unittests/type_info_test.cpp b/unittests/type_info_test.cpp index 361be80..3dba907 100644 --- a/unittests/type_info_test.cpp +++ b/unittests/type_info_test.cpp @@ -1,6 +1,7 @@ // Tests to make sure that the order in which function dispatches occur is correct #include +#include void test_type(const chaiscript::Type_Info &ti, bool t_is_const, bool t_is_pointer, bool t_is_reference, bool t_is_void, bool t_is_undef)