diff --git a/configure.ac b/configure.ac index 12557e2d14..046a7dcec4 100644 --- a/configure.ac +++ b/configure.ac @@ -845,6 +845,14 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include [ AC_MSG_RESULT(no)] ) +AC_MSG_CHECKING(for if type char equals int8_t) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + #include ]], + [[ static_assert(std::is_same::value, ""); ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(CHAR_EQUALS_INT8, 1,[Define this symbol if type char equals int8_t]) ], + [ AC_MSG_RESULT(no)] +) + # ensure backtrace() is found, check -lexecinfo if necessary if test x$TARGET_OS != xwindows; then AC_SEARCH_LIBS([backtrace], [execinfo], [], [ diff --git a/src/serialize.h b/src/serialize.h index 1c266c6582..26bc5b319b 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -186,7 +186,9 @@ template const X& ReadWriteAsHelper(const X& x) { return x; } SerializationOp(s, CSerActionUnserialize()); \ } +#ifndef CHAR_EQUALS_INT8 template inline void Serialize(Stream& s, char a ) { ser_writedata8(s, a); } // TODO Get rid of bare char +#endif template inline void Serialize(Stream& s, int8_t a ) { ser_writedata8(s, a); } template inline void Serialize(Stream& s, uint8_t a ) { ser_writedata8(s, a); } template inline void Serialize(Stream& s, int16_t a ) { ser_writedata16(s, a); } @@ -198,7 +200,9 @@ template inline void Serialize(Stream& s, uint64_t a) { ser_wri template inline void Serialize(Stream& s, float a ) { ser_writedata32(s, ser_float_to_uint32(a)); } template inline void Serialize(Stream& s, double a ) { ser_writedata64(s, ser_double_to_uint64(a)); } +#ifndef CHAR_EQUALS_INT8 template inline void Unserialize(Stream& s, char& a ) { a = ser_readdata8(s); } // TODO Get rid of bare char +#endif template inline void Unserialize(Stream& s, int8_t& a ) { a = ser_readdata8(s); } template inline void Unserialize(Stream& s, uint8_t& a ) { a = ser_readdata8(s); } template inline void Unserialize(Stream& s, int16_t& a ) { a = ser_readdata16(s); }