mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 09:01:38 +00:00
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.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
0cdacdfb35
commit
a1f14005ab
@@ -363,6 +363,11 @@ void WriteScalar(void *p, T t) {
|
|||||||
*reinterpret_cast<T *>(p) = EndianScalar(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
|
// 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
|
// "scalar_size" scalar if the buffer had grown to "buf_size" (downwards in
|
||||||
// memory).
|
// memory).
|
||||||
|
|||||||
Reference in New Issue
Block a user