Fix build in Ubuntu 18.04 clang 6.0.0 (#276)

* Fix build in Ubuntu 18.04 clang 6.0.0

* Globally allow double-promotion instead of on a case-by-case basis
This commit is contained in:
Jacob Wirth 2019-04-25 18:10:44 -04:00 коммит произвёл GitHub
Родитель 1e02477c5d
Коммит 29ef39dd66
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 2 добавлений и 14 удалений

Просмотреть файл

@ -24,6 +24,7 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
list(APPEND CLANG_ALL_WARNINGS "-Wno-documentation-unknown-command") # Allow undocumented documentation commands used by doxygen list(APPEND CLANG_ALL_WARNINGS "-Wno-documentation-unknown-command") # Allow undocumented documentation commands used by doxygen
list(APPEND CLANG_ALL_WARNINGS "-Wno-covered-switch-default") # Allow default: in switch statements that cover all enum values list(APPEND CLANG_ALL_WARNINGS "-Wno-covered-switch-default") # Allow default: in switch statements that cover all enum values
list(APPEND CLANG_ALL_WARNINGS "-Wno-unreachable-code-break") # Allow break even if it is unreachable list(APPEND CLANG_ALL_WARNINGS "-Wno-unreachable-code-break") # Allow break even if it is unreachable
list(APPEND CLANG_ALL_WARNINGS "-Wno-double-promotion") # Allow floats to be promoted to doubles. Needed for isnan() on some systems
if (NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "5.0.0")) if (NOT (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "5.0.0"))
# Added in clang 5 # Added in clang 5
list(APPEND CLANG_ALL_WARNINGS "-Wno-zero-as-null-pointer-constant") # Allow zero as nullptr list(APPEND CLANG_ALL_WARNINGS "-Wno-zero-as-null-pointer-constant") # Allow zero as nullptr
@ -46,4 +47,4 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
add_compile_options(${MSVC_WARNINGS_AS_ERRORS}) add_compile_options(${MSVC_WARNINGS_AS_ERRORS})
else() else()
message(FATAL_ERROR "Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}") message(FATAL_ERROR "Unknown C++ compiler: ${CMAKE_CXX_COMPILER_ID}")
endif() endif()

Просмотреть файл

@ -351,15 +351,6 @@ void capture_set_imu_image(k4a_capture_t capture_handle, k4a_image_t image_handl
capture_set_ir_image(capture_handle, image_handle); capture_set_ir_image(capture_handle, image_handle);
} }
// On Ubuntu 16.04 this works without warnings, but on Ubuntu 18.04 isnan actually
// takes a long double, we get a double-promotion warning here. Unfortunately,
// isnan has an implementation-defined argument type, so there's not a specific
// type we can cast it to in order to avoid clang's precision warnings, so we
// just need to suppress the warning.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdouble-promotion"
#endif
void capture_set_temperature_c(k4a_capture_t capture_handle, float temperature_c) void capture_set_temperature_c(k4a_capture_t capture_handle, float temperature_c)
{ {
RETURN_VALUE_IF_HANDLE_INVALID(VOID_VALUE, k4a_capture_t, capture_handle); RETURN_VALUE_IF_HANDLE_INVALID(VOID_VALUE, k4a_capture_t, capture_handle);
@ -369,10 +360,6 @@ void capture_set_temperature_c(k4a_capture_t capture_handle, float temperature_c
capture->temperature_c = temperature_c; capture->temperature_c = temperature_c;
} }
#ifdef __clang__
#pragma clang diagnostic pop
#endif
float capture_get_temperature_c(k4a_capture_t capture_handle) float capture_get_temperature_c(k4a_capture_t capture_handle)
{ {
RETURN_VALUE_IF_HANDLE_INVALID(NAN, k4a_capture_t, capture_handle); RETURN_VALUE_IF_HANDLE_INVALID(NAN, k4a_capture_t, capture_handle);