From 213736fb0d56a11ef1af182b600ed7be7025a8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Enrique=20Mu=C3=B1oz=20Mart=C3=ADn?= Date: Mon, 23 Oct 2017 11:39:26 +0200 Subject: [PATCH] fix endianness setup --- CMakeLists.txt | 2 +- cmake/dev/check_configuration.cmake | 5 +++++ include/microcdr/microcdr.h | 3 ++- src/c/microcdr.c | 6 +----- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93dead6..b7b69f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ endif() ############################################################################### include(${PROJECT_SOURCE_DIR}/cmake/dev/check_configuration.cmake) -option(CHECK_ENDIANNESS "Enable/disable endiannes checking" OFF) +option(CHECK_ENDIANNESS "Enable/disable endiannes checking" ON) if(CHECK_ENDIANNESS) check_endianness() else() diff --git a/cmake/dev/check_configuration.cmake b/cmake/dev/check_configuration.cmake index d662811..118fb9a 100644 --- a/cmake/dev/check_configuration.cmake +++ b/cmake/dev/check_configuration.cmake @@ -48,6 +48,11 @@ macro(check_endianness) # Test endianness include(TestBigEndian) test_big_endian(BIG_ENDIAN) + if(BIG_ENDIAN) + message(STATUS "Machine: big endian") + else() + message(STATUS "Machine: little endian") + endif() set(__BIG_ENDIAN__ ${BIG_ENDIAN}) endmacro() diff --git a/include/microcdr/microcdr.h b/include/microcdr/microcdr.h index bf06fe8..c0fe168 100644 --- a/include/microcdr/microcdr.h +++ b/include/microcdr/microcdr.h @@ -17,7 +17,8 @@ extern "C" typedef enum Endianness { - BIG_ENDIANNESS, LITTLE_ENDIANNESS + BIG_ENDIANNESS, + LITTLE_ENDIANNESS } Endianness; diff --git a/src/c/microcdr.c b/src/c/microcdr.c index a5b0d0f..0b678da 100644 --- a/src/c/microcdr.c +++ b/src/c/microcdr.c @@ -3,11 +3,7 @@ #include #include -#ifdef __BIG_ENDIAN__ -#define MACHINE_ENDIANNESS BIG_ENDIANNESS -#else -#define MACHINE_ENDIANNESS LITTLE_ENDIANNESS -#endif +#define MACHINE_ENDIANNESS !__BIG_ENDIAN__ // ------------------------------------------------------------------- // INTERNAL SERIALIZATION FUNCTIONS