mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
run-time validate endianness, numeric sizes
This commit is contained in:
parent
1ea11e7073
commit
26b1e8f6cd
@ -30,6 +30,7 @@
|
|||||||
#include "virtualFileMountSystem.h"
|
#include "virtualFileMountSystem.h"
|
||||||
#include "virtualFileSimple.h"
|
#include "virtualFileSimple.h"
|
||||||
#include "pandaSystem.h"
|
#include "pandaSystem.h"
|
||||||
|
#include "numeric_types.h"
|
||||||
|
|
||||||
#include "dconfig.h"
|
#include "dconfig.h"
|
||||||
|
|
||||||
@ -168,6 +169,24 @@ init_libexpress() {
|
|||||||
ps->add_system("zlib");
|
ps->add_system("zlib");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This is a fine place to ensure that the numeric types have been
|
||||||
|
// chosen correctly.
|
||||||
|
nassertv(sizeof(PN_int8) == 1 && sizeof(PN_uint8) == 1);
|
||||||
|
nassertv(sizeof(PN_int16) == 2 && sizeof(PN_uint16) == 2);
|
||||||
|
nassertv(sizeof(PN_int32) == 4 && sizeof(PN_uint32) == 4);
|
||||||
|
nassertv(sizeof(PN_int64) == 8 && sizeof(PN_uint64) == 8);
|
||||||
|
nassertv(sizeof(PN_float32) == 4);
|
||||||
|
nassertv(sizeof(PN_float64) == 8);
|
||||||
|
|
||||||
|
// Also, ensure that we have the right endianness.
|
||||||
|
PN_uint32 word;
|
||||||
|
memcpy(&word, "\1\2\3\4", 4);
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
nassertv(word == 0x01020304);
|
||||||
|
#else
|
||||||
|
nassertv(word == 0x04030201);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user