Commit a1f14005 authored by Brian Wellington's avatar Brian Wellington Committed by Wouter van Oortmerssen

Fix big-endian build. (#5205)

For some reason, Offset<T> is being considered a scalar, which
causes EndianSwap to be passed an Offset<T>.  This doesn't work,
as it does not support types with non-trivial constructors.  This
change adds an overload to WriteScalar(), which works around this.
parent 0cdacdfb
......@@ -363,6 +363,11 @@ void WriteScalar(void *p, T t) {
*reinterpret_cast<T *>(p) = EndianScalar(t);
}
template<typename T> struct Offset;
template<typename T> __supress_ubsan__("alignment") void WriteScalar(void *p, Offset<T> t) {
*reinterpret_cast<uoffset_t *>(p) = EndianScalar(t.o);
}
// Computes how many bytes you'd have to pad to be able to write an
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
// memory).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment