File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- cmake_minimum_required (VERSION 3.25...4.2 )
1+ cmake_minimum_required (VERSION 3.25...4.4 )
22# 3.19 for CheckSourceCompiles
33# 3.25 for block()
44
Original file line number Diff line number Diff line change 11set_property (DIRECTORY PROPERTY LABELS nullptr)
22
3+ block ()
4+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
5+ set (CMAKE_C_STANDARD 23)
6+ # test has nullptr_t otherwise you're testing for a macro but not the type
7+ check_source_compiles (C "#include <stddef.h>
8+ nullptr_t p = nullptr;"
9+ c23_nullptr
10+ )
11+ endblock ()
12+
13+ if (c23_nullptr)
314add_library (c_nullptr OBJECT lib.c )
4- target_include_directories (c_nullptr PRIVATE . )
15+ target_include_directories (c_nullptr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR } )
16+ target_compile_features (c_nullptr PRIVATE c_std_23 )
17+ endif ()
18+
519add_library (cpp_nullptr OBJECT lib.cpp )
6- target_include_directories (cpp_nullptr PRIVATE . )
20+ target_include_directories (cpp_nullptr PRIVATE ${ CMAKE_CURRENT_SOURCE_DIR } )
721
22+ if (TARGET c_nullptr)
823add_executable (C_Fortran_nullptr main.f90 $<TARGET_OBJECTS :c_nullptr >)
924add_test (NAME C_Nullptr COMMAND C_Fortran_nullptr )
25+ endif ()
1026
1127add_executable (Cpp_Fortran_nullptr main.f90 $<TARGET_OBJECTS :cpp_nullptr >)
1228set_property (TARGET Cpp_Fortran_nullptr PROPERTY LINKER_LANGUAGE ${linker_lang} )
Original file line number Diff line number Diff line change 1- #include <nullptr.h>
21#include <stddef.h>
32
3+ #if __STDC_VERSION__ < 202311L
4+ #include <stdbool.h>
5+ #endif
6+
47const char * nullchar (bool b ) {
5- return b ? NULL : "hello" ;
8+ return b ? nullptr : "hello" ;
69}
You can’t perform that action at this time.
0 commit comments