Skip to content

Commit

Permalink
fix endianness setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Oct 23, 2017
1 parent bbe0322 commit 213736f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions cmake/dev/check_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion include/microcdr/microcdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ extern "C"

typedef enum Endianness
{
BIG_ENDIANNESS, LITTLE_ENDIANNESS
BIG_ENDIANNESS,
LITTLE_ENDIANNESS

} Endianness;

Expand Down
6 changes: 1 addition & 5 deletions src/c/microcdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
#include <string.h>
#include <stdlib.h>

#ifdef __BIG_ENDIAN__
#define MACHINE_ENDIANNESS BIG_ENDIANNESS
#else
#define MACHINE_ENDIANNESS LITTLE_ENDIANNESS
#endif
#define MACHINE_ENDIANNESS !__BIG_ENDIAN__

// -------------------------------------------------------------------
// INTERNAL SERIALIZATION FUNCTIONS
Expand Down

0 comments on commit 213736f

Please sign in to comment.