From 18330f7ab7425d6e8b0fc2a6c8fa11983058d3e1 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi <lucas.demarchi@intel.com> Date: Thu, 7 Jul 2016 18:06:43 -0300 Subject: [PATCH] Move __STDC_FORMAT_MACROS to build system __STDC_FORMAT_MACROS changes the behavior of inttypes.h to allow defining format macros for printf-like functions. It needs to be defined before any include is done, otherwise due to include chains and header guards it may not take effect. Instead of having to define it everywhere it is used, move the define to the build system. Also update ecl and DriverFramework submodules to deal with the changed definitions. --- Tools/generate_listener.py | 1 - cmake/common/px4_base.cmake | 1 + src/drivers/drv_hrt.h | 1 - src/drivers/px4flow/i2c_frame.h | 1 - src/lib/DriverFramework | 2 +- src/lib/controllib/block/Block.hpp | 1 - src/lib/ecl | 2 +- src/modules/px4iofirmware/protocol.h | 1 - src/modules/systemlib/err.c | 1 - src/modules/systemlib/uthash/uthash.h | 1 - src/platforms/posix/drivers/barosim/baro.cpp | 1 - src/platforms/posix/drivers/gpssim/gpssim.cpp | 1 - src/platforms/posix/drivers/gyrosim/gyrosim.cpp | 1 - src/platforms/posix/px4_layer/drv_hrt.c | 1 - src/platforms/px4_log.h | 1 - src/platforms/px4_nodehandle.h | 1 - src/systemcmds/tests/test_bson.c | 1 - src/systemcmds/tests/test_int.c | 1 - 18 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Tools/generate_listener.py b/Tools/generate_listener.py index d3b4f27d0e..59cd79c7bd 100755 --- a/Tools/generate_listener.py +++ b/Tools/generate_listener.py @@ -115,7 +115,6 @@ print(""" #include <stdint.h> #include <stdio.h> #include <stdlib.h> -#define __STDC_FORMAT_MACROS #include <inttypes.h> #ifndef PRIu64 diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 70b2a7d854..7b65c35071 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -787,6 +787,7 @@ function(px4_add_common_flags) string(REPLACE "-" "_" board_config ${board_upper}) set(added_definitions -DCONFIG_ARCH_BOARD_${board_config} + -D__STDC_FORMAT_MACROS ) if (NOT (APPLE AND (${CMAKE_C_COMPILER_ID} MATCHES ".*Clang.*"))) diff --git a/src/drivers/drv_hrt.h b/src/drivers/drv_hrt.h index beaf9b1ad9..befbfe799d 100644 --- a/src/drivers/drv_hrt.h +++ b/src/drivers/drv_hrt.h @@ -41,7 +41,6 @@ #include <sys/types.h> #include <stdbool.h> -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <px4_time.h> diff --git a/src/drivers/px4flow/i2c_frame.h b/src/drivers/px4flow/i2c_frame.h index f73d4a92cc..ec8a5e1fda 100644 --- a/src/drivers/px4flow/i2c_frame.h +++ b/src/drivers/px4flow/i2c_frame.h @@ -41,7 +41,6 @@ #ifndef I2C_FRAME_H_ #define I2C_FRAME_H_ -#define __STDC_FORMAT_MACROS #include <inttypes.h> typedef struct i2c_frame { diff --git a/src/lib/DriverFramework b/src/lib/DriverFramework index 7c468a60ae..ed8550b1ec 160000 --- a/src/lib/DriverFramework +++ b/src/lib/DriverFramework @@ -1 +1 @@ -Subproject commit 7c468a60ae64726fb42989fe552feb21b7978289 +Subproject commit ed8550b1ec4d8a71e3512bb6712e28e8f4d8a6cc diff --git a/src/lib/controllib/block/Block.hpp b/src/lib/controllib/block/Block.hpp index e74258b523..7c2fd4a524 100644 --- a/src/lib/controllib/block/Block.hpp +++ b/src/lib/controllib/block/Block.hpp @@ -39,7 +39,6 @@ #pragma once -#define __STDC_FORMAT_MACROS #include <stdint.h> #include <inttypes.h> diff --git a/src/lib/ecl b/src/lib/ecl index a2d866520a..63b95a1738 160000 --- a/src/lib/ecl +++ b/src/lib/ecl @@ -1 +1 @@ -Subproject commit a2d866520a0477574d0ade68b0f5e7becb57431b +Subproject commit 63b95a17382bb4f930ac56ae2ddf6fdeb157ac73 diff --git a/src/modules/px4iofirmware/protocol.h b/src/modules/px4iofirmware/protocol.h index f61e56d204..6c984ccac5 100644 --- a/src/modules/px4iofirmware/protocol.h +++ b/src/modules/px4iofirmware/protocol.h @@ -33,7 +33,6 @@ #pragma once -#define __STDC_FORMAT_MACROS #include <inttypes.h> /** diff --git a/src/modules/systemlib/err.c b/src/modules/systemlib/err.c index 78e3058068..469c06175b 100644 --- a/src/modules/systemlib/err.c +++ b/src/modules/systemlib/err.c @@ -40,7 +40,6 @@ #include <px4_config.h> -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <stdlib.h> diff --git a/src/modules/systemlib/uthash/uthash.h b/src/modules/systemlib/uthash/uthash.h index a8642833f6..9f83fc34f1 100644 --- a/src/modules/systemlib/uthash/uthash.h +++ b/src/modules/systemlib/uthash/uthash.h @@ -61,7 +61,6 @@ do { typedef unsigned int uint32_t; typedef unsigned char uint8_t; #else -#define __STDC_FORMAT_MACROS #include <inttypes.h> /* uint32_t */ #endif diff --git a/src/platforms/posix/drivers/barosim/baro.cpp b/src/platforms/posix/drivers/barosim/baro.cpp index 0ab376ed3d..248a20fef8 100644 --- a/src/platforms/posix/drivers/barosim/baro.cpp +++ b/src/platforms/posix/drivers/barosim/baro.cpp @@ -36,7 +36,6 @@ * Driver for the simulated barometric pressure sensor */ -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <px4_config.h> #include <px4_defines.h> diff --git a/src/platforms/posix/drivers/gpssim/gpssim.cpp b/src/platforms/posix/drivers/gpssim/gpssim.cpp index 0b3f4ba2b2..8eb462585a 100644 --- a/src/platforms/posix/drivers/gpssim/gpssim.cpp +++ b/src/platforms/posix/drivers/gpssim/gpssim.cpp @@ -37,7 +37,6 @@ */ #include <sys/types.h> -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <stdio.h> #include <stdbool.h> diff --git a/src/platforms/posix/drivers/gyrosim/gyrosim.cpp b/src/platforms/posix/drivers/gyrosim/gyrosim.cpp index 6fb35a7dbe..349fe461c6 100644 --- a/src/platforms/posix/drivers/gyrosim/gyrosim.cpp +++ b/src/platforms/posix/drivers/gyrosim/gyrosim.cpp @@ -41,7 +41,6 @@ * @author Mark Charlebois */ -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <px4_config.h> diff --git a/src/platforms/posix/px4_layer/drv_hrt.c b/src/platforms/posix/px4_layer/drv_hrt.c index bdd8dfd786..70a9c5f02d 100644 --- a/src/platforms/posix/px4_layer/drv_hrt.c +++ b/src/platforms/posix/px4_layer/drv_hrt.c @@ -45,7 +45,6 @@ #include <semaphore.h> #include <time.h> #include <string.h> -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <errno.h> #include "hrt_work.h" diff --git a/src/platforms/px4_log.h b/src/platforms/px4_log.h index 53af0bb2ed..1eb13a0e77 100644 --- a/src/platforms/px4_log.h +++ b/src/platforms/px4_log.h @@ -118,7 +118,6 @@ static inline void do_nothing(int level, ...) #else -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <stdint.h> #include <sys/cdefs.h> diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index 31afbfd031..9ae11474de 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -48,7 +48,6 @@ /* includes when building for ros */ #include "ros/ros.h" #include <list> -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <type_traits> #else diff --git a/src/systemcmds/tests/test_bson.c b/src/systemcmds/tests/test_bson.c index 945b00aa51..7a168cac5a 100644 --- a/src/systemcmds/tests/test_bson.c +++ b/src/systemcmds/tests/test_bson.c @@ -37,7 +37,6 @@ * Tests for the bson en/decoder */ -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <px4_defines.h> diff --git a/src/systemcmds/tests/test_int.c b/src/systemcmds/tests/test_int.c index 01092aa2d4..7db4b48f9b 100644 --- a/src/systemcmds/tests/test_int.c +++ b/src/systemcmds/tests/test_int.c @@ -36,7 +36,6 @@ * Included Files ****************************************************************************/ -#define __STDC_FORMAT_MACROS #include <inttypes.h> #include <px4_config.h> -- GitLab