Skip to content

Commit 40334c7

Browse files
committed
Merge #13580: build: Detect if char equals int8_t
49d1f4c Detect if char equals int8_t (Chun Kuan Lee) Pull request description: Probably fixes #13576. I'm not able to test this. @stacepellegrino, can you test this? Tree-SHA512: b750e00e11e6b6f6341fec668ec2254cc101c8ebdd4878f320d6cb3b07cf326761146e4ceff0b6405b7e503ff64c093a8274bd524a097e2c49382dc296972c4f
2 parents b77c38e + 49d1f4c commit 40334c7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,14 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
808808
[ AC_MSG_RESULT(no)]
809809
)
810810

811+
AC_MSG_CHECKING(for if type char equals int8_t)
812+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>
813+
#include <type_traits>]],
814+
[[ static_assert(std::is_same<int8_t, char>::value, ""); ]])],
815+
[ AC_MSG_RESULT(yes); AC_DEFINE(CHAR_EQUALS_INT8, 1,[Define this symbol if type char equals int8_t]) ],
816+
[ AC_MSG_RESULT(no)]
817+
)
818+
811819
# Check for reduced exports
812820
if test x$use_reduce_exports = xyes; then
813821
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"],

src/serialize.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ template<typename X> const X& ReadWriteAsHelper(const X& x) { return x; }
189189
SerializationOp(s, CSerActionUnserialize()); \
190190
}
191191

192+
#ifndef CHAR_EQUALS_INT8
192193
template<typename Stream> inline void Serialize(Stream& s, char a ) { ser_writedata8(s, a); } // TODO Get rid of bare char
194+
#endif
193195
template<typename Stream> inline void Serialize(Stream& s, int8_t a ) { ser_writedata8(s, a); }
194196
template<typename Stream> inline void Serialize(Stream& s, uint8_t a ) { ser_writedata8(s, a); }
195197
template<typename Stream> inline void Serialize(Stream& s, int16_t a ) { ser_writedata16(s, a); }
@@ -205,7 +207,9 @@ template<typename Stream, int N> inline void Serialize(Stream& s, const unsigned
205207
template<typename Stream> inline void Serialize(Stream& s, const Span<const unsigned char>& span) { s.write(CharCast(span.data()), span.size()); }
206208
template<typename Stream> inline void Serialize(Stream& s, const Span<unsigned char>& span) { s.write(CharCast(span.data()), span.size()); }
207209

210+
#ifndef CHAR_EQUALS_INT8
208211
template<typename Stream> inline void Unserialize(Stream& s, char& a ) { a = ser_readdata8(s); } // TODO Get rid of bare char
212+
#endif
209213
template<typename Stream> inline void Unserialize(Stream& s, int8_t& a ) { a = ser_readdata8(s); }
210214
template<typename Stream> inline void Unserialize(Stream& s, uint8_t& a ) { a = ser_readdata8(s); }
211215
template<typename Stream> inline void Unserialize(Stream& s, int16_t& a ) { a = ser_readdata16(s); }

0 commit comments

Comments
 (0)