test for, and use, nullptr if we have it
This commit is contained in:
parent
4e88ad69eb
commit
bc5533bda8
8 changed files with 41 additions and 6 deletions
|
|
@ -114,6 +114,9 @@ elseif(BORLAND)
|
|||
add_definitions(-D__BORLAND__ -D__WIN32__)
|
||||
else()
|
||||
add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long)
|
||||
if(HAVE_NULLPTR)
|
||||
list(APPEND CMAKE_CXX_FLAGS -std=c++11)
|
||||
endif(HAVE_NULLPTR)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ int main() {
|
|||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
set( CMAKE_REQUIRED_FLAGS "-pthread -std=c++0x" )
|
||||
set( CMAKE_REQUIRED_FLAGS "-pthread -std=c++11" )
|
||||
else( UNIX )
|
||||
# vars probably need set for embarcadero, etc
|
||||
endif( UNIX )
|
||||
|
|
@ -74,13 +74,27 @@ int main() {
|
|||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
set( CMAKE_REQUIRED_FLAGS "-std=c++0x" )
|
||||
set( CMAKE_REQUIRED_FLAGS "-std=c++11" )
|
||||
else( UNIX )
|
||||
# vars probably need set for embarcadero, etc
|
||||
endif( UNIX )
|
||||
CHECK_CXX_SOURCE_RUNS( "${TEST_STD_CHRONO}" HAVE_STD_CHRONO ) #quotes are *required*!
|
||||
cmake_pop_check_state()
|
||||
|
||||
set( TEST_NULLPTR "
|
||||
#include <cstddef>
|
||||
std::nullptr_t f() {return nullptr;}
|
||||
int main() {return !!f();}
|
||||
" )
|
||||
cmake_push_check_state()
|
||||
if( UNIX )
|
||||
set( CMAKE_REQUIRED_FLAGS "-std=c++11" )
|
||||
else( UNIX )
|
||||
# vars probably need set for embarcadero, etc
|
||||
endif( UNIX )
|
||||
CHECK_CXX_SOURCE_RUNS( "${TEST_NULLPTR}" HAVE_NULLPTR ) #quotes are *required*!
|
||||
cmake_pop_check_state()
|
||||
|
||||
# Now that all the tests are done, configure the sc_cf.h file:
|
||||
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
|
||||
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")
|
||||
|
|
|
|||
|
|
@ -25,5 +25,6 @@
|
|||
|
||||
#cmakedefine HAVE_STD_THREAD 1
|
||||
#cmakedefine HAVE_STD_CHRONO 1
|
||||
#cmakedefine HAVE_NULLPTR 1
|
||||
|
||||
#endif /* SCL_CF_H */
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ set(SC_BASE_HDRS
|
|||
sc_getopt.h
|
||||
sc_trace_fprintf.h
|
||||
sc_mkdir.h
|
||||
sc_nullptr.h
|
||||
path2str.h
|
||||
)
|
||||
|
||||
|
|
|
|||
13
src/base/sc_nullptr.h
Normal file
13
src/base/sc_nullptr.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef NULLPTR_H
|
||||
#define NULLPTR_H
|
||||
|
||||
#include <sc_cf.h>
|
||||
|
||||
#ifdef HAVE_NULLPTR
|
||||
#include <cstddef>
|
||||
#else
|
||||
# define nullptr_t void*
|
||||
# define nullptr NULL
|
||||
#endif //HAVE_NULLPTR
|
||||
|
||||
#endif //NULLPTR_H
|
||||
|
|
@ -19,20 +19,21 @@
|
|||
class GenericNode;
|
||||
class DisplayNode;
|
||||
#include <sdai.h>
|
||||
//class SDAI_Application_instance;
|
||||
|
||||
#include <gennode.h>
|
||||
#include <gennodelist.h>
|
||||
//#include <gennode.inline.h>
|
||||
|
||||
#include <editordefines.h>
|
||||
|
||||
#include <sc_nullptr.h>
|
||||
|
||||
class InstMgr;
|
||||
|
||||
class SC_CORE_EXPORT MgrNodeBase : public GenericNode {
|
||||
public:
|
||||
virtual inline SDAI_Application_instance * GetSTEPentity() {
|
||||
abort();
|
||||
return nullptr;
|
||||
};
|
||||
virtual ~MgrNodeBase() {};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
#include "sdaiApplication_instance.h"
|
||||
#include "superInvAttrIter.h"
|
||||
|
||||
#include <sc_nullptr.h>
|
||||
|
||||
SDAI_Application_instance NilSTEPentity;
|
||||
|
||||
/**************************************************************//**
|
||||
|
|
@ -944,7 +946,7 @@ const SDAI_Application_instance::iAMap_t::value_type SDAI_Application_instance::
|
|||
}
|
||||
iAstruct z;
|
||||
memset( &z, 0, sizeof z );
|
||||
iAMap_t::value_type nil( NULL, z );
|
||||
iAMap_t::value_type nil( nullptr, z );
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ add_schema_dependent_test( "attribute" "inverse_attr" "${SC_SOURCE_DIR}/test/p21
|
|||
|
||||
if(HAVE_STD_THREAD)
|
||||
if(UNIX)
|
||||
set(thread_flags "-pthread -std=c++0x" )
|
||||
set(thread_flags "-pthread -std=c++11" )
|
||||
set(thread_libs "pthread")
|
||||
endif(UNIX)
|
||||
# for best results, use a large file. as1-oc-214.stp is currently the largest file in the repo that sc works with.
|
||||
|
|
|
|||
Loading…
Reference in a new issue