Skip to content

Commit

Permalink
FIX: check #if defined() otherwise -Wundef errors
Browse files Browse the repository at this point in the history
  • Loading branch information
justadreamer committed Nov 4, 2024
1 parent 47d16c7 commit 8a08351
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,16 @@ add_library(fiftyone-common-cxx ${COMCPP_SRC} ${COMCPP_H})
target_link_libraries(fiftyone-common-cxx fiftyone-common-c)

set_target_properties(fiftyone-common-c fiftyone-common-cxx PROPERTIES FOLDER "Common")

set(COMMON_C_COMPILE_OPTIONS "${COMPILE_OPTION_DEBUG} -Werror -Wundef -Wno-atomic-alignment -Wno-unused-variable -Wno-unused-result -Wno-unused-but-set-variable")
separate_arguments(COMMON_C_COMPILE_OPTIONS)

if (MSVC)
target_compile_options(fiftyone-common-c PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX")
target_compile_options(fiftyone-common-cxx PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX")
else ()
target_compile_options(fiftyone-common-c PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror" "-Wno-atomic-alignment")
target_compile_options(fiftyone-common-cxx PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
target_compile_options(fiftyone-common-c PRIVATE ${COMMON_C_COMPILE_OPTIONS})
target_compile_options(fiftyone-common-cxx PRIVATE ${COMMON_C_COMPILE_OPTIONS})
if (TESTCOVERAGE_ENABLED)
message("-- fiftyone-common-c(xx)-cov adding targets with code coverage")
add_library(fiftyone-common-c-cov ${COMC_SRC} ${COMC_H})
Expand All @@ -138,8 +142,8 @@ else ()
target_compile_options(fiftyone-common-c-cov PRIVATE "--coverage")
target_compile_options(fiftyone-common-cxx-cov PRIVATE "--coverage")
set_target_properties(fiftyone-common-c-cov fiftyone-common-cxx-cov PROPERTIES FOLDER "Common")
target_compile_options(fiftyone-common-c-cov PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror" "-Wno-atomic-alignment")
target_compile_options(fiftyone-common-cxx-cov PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
target_compile_options(fiftyone-common-c-cov PRIVATE ${COMMON_C_COMPILE_OPTIONS})
target_compile_options(fiftyone-common-cxx-cov PRIVATE ${COMMON_C_COMPILE_OPTIONS})
endif()
endif()

Expand All @@ -151,7 +155,7 @@ if (MSVC)
target_compile_options(CachePerf PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX")
target_link_options(CachePerf PRIVATE "/WX")
else ()
target_compile_options(CachePerf PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror")
target_compile_options(CachePerf PRIVATE ${COMMON_C_COMPILE_OPTIONS})
endif()
set_target_properties(CachePerf PROPERTIES FOLDER "Examples/Common")

Expand Down Expand Up @@ -200,7 +204,7 @@ if(BUILD_TESTING)
target_compile_options(CommonTests PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX")
target_link_options(CommonTests PRIVATE "/WX")
else ()
target_compile_options(CommonTests PRIVATE ${COMPILE_OPTION_DEBUG})
target_compile_options(CommonTests PRIVATE ${COMMON_C_COMPILE_OPTIONS})
if (lower_CMAKE_BUILD_TYPE STREQUAL "debug")
message("-- CommonTests Linker options for code coverage")
target_link_options(CommonTests PRIVATE "-fprofile-arcs" "-ftest-coverage")
Expand All @@ -216,8 +220,4 @@ if(BUILD_TESTING)

gtest_discover_tests(CommonTests PROPERTIES TEST_DISCOVERY_TIMEOUT 600 DISCOVERY_MODE PRE_TEST)
set_target_properties(CommonTests PROPERTIES FOLDER "Tests")

if (CMAKE_COMPILER_IS_GNUCC)
target_compile_options(CommonTests PRIVATE "-Wall" "-Werror" "-Wno-unused-variable" "-Wno-unused-result" "-Wno-unused-but-set-variable")
endif()
endif()
2 changes: 1 addition & 1 deletion float.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ EXTERNAL int fiftyoneDegreesFloatIsEqual(fiftyoneDegreesFloatInternal f1, fiftyo
* the IEEE single precision standard is supported, default the type
* to the native float type.
*/
#if _MSC_VER || (FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125)
#if defined(_MSC_VER) || (defined(FLT_RADIX) && FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125)
/**
* Define 51Degrees float implementation as native float.
*/
Expand Down
4 changes: 2 additions & 2 deletions threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ void fiftyoneDegreesSignalWait(fiftyoneDegreesSignal *signal) {
#endif

bool fiftyoneDegreesThreadingGetIsThreadSafe() {
#if FIFTYONE_DEGREES_NO_THREADING
#if defined(FIFTYONE_DEGREES_NO_THREADING) && FIFTYONE_DEGREES_NO_THREADING
return false;
#else
return true;
#endif
}
}

0 comments on commit 8a08351

Please sign in to comment.