johnsonjh / duma

duma: Detect Unintended Memory Access (D.U.M.A.) - A Red-Zone memory allocator

Home Page:https://github.com/johnsonjh/duma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CXX Standard

kheaactua opened this issue · comments

Without altering the C++ Standard in the CMake file, I kept running into errors like:

duma/src/dumapp.cpp:198:18: error: declaration of 'void* operator new(size_t, const std::nothrow_t&) throw ()' has a different exception specifier                                                                 
 void *DUMA_CDECL operator new(DUMA_SIZE_T size,                                                                                                                                                                                              
                  ^~~~~~~~                                                                                                                                                                                                                    
In file included from local/duma/src/dumapp.cpp:38:                                                                                                                                                                      
/duma/dumapp.h:94:18: note: from previous declaration 'void* operator new(size_t, const std::nothrow_t&)'                                                                                                           
 void *DUMA_CDECL operator new(DUMA_SIZE_T, const std::nothrow_t &) throw(); 

In addition, to build on QNX, I also had to tweak how threads were linked against:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18d9eec..f3b4499 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,8 +3,10 @@ project(DUMA C CXX)
 
 # See README.md for help building and using DUMA
 
-set(CMAKE_CXX_STANDARD 98)
-set(CMAKE_CXX_STANDARD_REQUIRED off)
+find_package(Threads)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 if(POLICY CMP0063)
   cmake_policy(SET CMP0063 NEW)
@@ -190,7 +192,7 @@ endif()
 if (NOT DUMA_WITH_THREAD_SAFETY)
   target_compile_definitions(DUMA_STATIC PRIVATE DUMA_NO_THREAD_SAFETY)
 else()
-  target_link_libraries(DUMA_STATIC PUBLIC pthread)
+  target_link_libraries(DUMA_STATIC PUBLIC $<$<NOT:$<PLATFORM_ID:QNX>>:Threads::Threads>)
 endif()
 if (NOT DUMA_WITH_STRERROR)
   target_compile_definitions(DUMA_STATIC PRIVATE DUMA_NO_STRERROR)
@@ -236,7 +238,7 @@ if (WIN32 AND MINGW)
   message(STATUS "MINGW")
 else()
   message(STATUS "target link pthread to DUMA_SHARED")
-  target_link_libraries( DUMA_SHARED PUBLIC pthread )
+  target_link_libraries( DUMA_SHARED PUBLIC $<$<NOT:$<PLATFORM_ID:QNX>>:Threads::Threads> )
 endif()

Thanks for the report (and building on QNX).

I'll try to take a look at this over the weekend.

Thanks. I have it set up to work on QNX now, I have it working on small test apps, but I'm stuck on the word alignment issue for a bigger lib.

Anyways, I'm happy to help of I can in any way.