Skip to content

Commit

Permalink
Merge pull request #77 from eProsima/bugfrix/endianness_macro
Browse files Browse the repository at this point in the history
Set and check endianness with FASTCDR_IS_BIG_ENDIAN_TARGET
  • Loading branch information
EduPonz authored Sep 1, 2020
2 parents c5668b9 + 82a2a4e commit 721b99e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmake/common/check_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ macro(check_endianness)
# Test endianness
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
set(__BIG_ENDIAN__ ${BIG_ENDIAN})
set(FASTCDR_IS_BIG_ENDIAN_TARGET ${BIG_ENDIAN})
endmacro()

macro(check_msvc_arch)
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ AS_IF([test $HAVE_CXX11 = 1],

# Check endianess
AC_C_BIGENDIAN(
AC_DEFINE(__BIG_ENDIAN__, 1, [machine is bigendian]),
AC_DEFINE(__BIG_ENDIAN__, 0, [machine is littleendian]),
AC_DEFINE(FASTCDR_IS_BIG_ENDIAN_TARGET, 1, [machine is bigendian]),
AC_DEFINE(FASTCDR_IS_BIG_ENDIAN_TARGET, 0, [machine is littleendian]),
AC_MSG_ERROR(unknown endianess),
AC_MSG_ERROR(universial endianess not supported)
)
Expand Down
4 changes: 2 additions & 2 deletions include/fastcdr/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#endif

// Endianness defines
#ifndef __BIG_ENDIAN__
#define __BIG_ENDIAN__ @__BIG_ENDIAN__@
#ifndef FASTCDR_IS_BIG_ENDIAN_TARGET
#define FASTCDR_IS_BIG_ENDIAN_TARGET @FASTCDR_IS_BIG_ENDIAN_TARGET@
#endif

#if defined(__ARM_ARCH) && __ARM_ARCH <= 7
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/Cdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using namespace eprosima::fastcdr;
using namespace ::exception;

#if __BIG_ENDIAN__
#if FASTCDR_IS_BIG_ENDIAN_TARGET
const Cdr::Endianness Cdr::DEFAULT_ENDIAN = BIG_ENDIANNESS;
#else
const Cdr::Endianness Cdr::DEFAULT_ENDIAN = LITTLE_ENDIANNESS;
Expand Down

0 comments on commit 721b99e

Please sign in to comment.