diff --git a/CMakeLists.txt b/CMakeLists.txt index dc35dc2..a5b38f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,18 +4,18 @@ project(Arbutils) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") set(CMAKE_CXX_STANDARD 17) -file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp") -if (SHARED) - add_library(Arbutils SHARED ${SRC_FILES}) -else() - add_library(Arbutils STATIC ${SRC_FILES}) -endif(SHARED) -set_target_properties(Arbutils PROPERTIES LINKER_LANGUAGE CXX) - if (WINDOWS) ADD_DEFINITIONS(-D WINDOWS=1) endif (WINDOWS) +file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp") +set(LIBTYPE STATIC) +if (SHARED) + set(LIBTYPE SHARED) +endif(SHARED) +add_library(Arbutils ${LIBTYPE} ${SRC_FILES}) + + file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") if (NOT DEFINED CONAN_EXPORTED) add_executable(ArbutilsTests ${TEST_FILES} extern/catch.hpp) diff --git a/src/ConstString.cpp b/src/ConstString.cpp index cddff04..b8daf68 100644 --- a/src/ConstString.cpp +++ b/src/ConstString.cpp @@ -1,4 +1,4 @@ #include "ConstString.hpp" -Arbutils::__ConstStringCharHolder* Arbutils::CaseInsensitiveConstString::__emptyString = nullptr; -Arbutils::__ConstStringCharHolder* Arbutils::ConstString::__emptyString = nullptr; \ No newline at end of file +Arbutils::__ConstStringCharHolder* Arbutils::CaseInsensitiveConstString::__emptyString = new __ConstStringCharHolder("", 0);; +Arbutils::__ConstStringCharHolder* Arbutils::ConstString::__emptyString = new __ConstStringCharHolder("", 0);; \ No newline at end of file diff --git a/src/__ConstStringCore.hpp b/src/__ConstStringCore.hpp index 9f3bb9c..ffd217e 100644 --- a/src/__ConstStringCore.hpp +++ b/src/__ConstStringCore.hpp @@ -17,11 +17,7 @@ hashFunction; \ \ static __ConstStringCharHolder* __emptyString; \ - static inline __ConstStringCharHolder* GetEmptyString() { \ - if (__emptyString == nullptr) \ - __emptyString = new __ConstStringCharHolder("", 0); \ - return __emptyString; \ - } \ + static inline __ConstStringCharHolder* GetEmptyString() { return __emptyString; } \ \ inline static int constexpr Length(const char* str) { return *str ? 1 + Length(str + 1) : 0; } \ inline __ConstStringCharHolder* CloneHolder() const noexcept { \