From d3fef998444c21142fa12b9bf698a73ee5706fd6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 26 Jun 2021 00:51:32 +0300 Subject: libcamera: utils: Only enable utils::hex() for integer arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The utils::hex() function is defined as a function template that has implementations for integer arguments only. When given a different argument type, the compiler will not catch the issue, but linking will fail: src/libcamera/libcamera.so.p/camera_sensor.cpp.o: in function `libcamera::CameraSensor::validateSensorDriver()': camera_sensor.cpp:(.text+0x1e6b): undefined reference to `libcamera::utils::_hex libcamera::utils::hex(libcamera::ControlId const*, unsigned int)' Move the failure to compilation time by enabling the function for integer arguments only. This provides better diagnostics: ../../src/libcamera/camera_sensor.cpp: In member function ‘int libcamera::CameraSensor::validateSensorDriver()’: ../../src/libcamera/camera_sensor.cpp:199:77: error: no matching function for call to ‘hex(const libcamera::ControlId*&)’ Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- include/libcamera/base/utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 07685045..52301254 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -84,7 +85,8 @@ std::basic_ostream> & operator<<(std::basic_ostream> &stream, const _hex &h); #endif -template +template::value> * = nullptr> _hex hex(T value, unsigned int width = 0); #ifndef __DOXYGEN__ -- cgit v1.2.1