Move static_asserts to the bottom

This commit is contained in:
Anonymous Maarten 2025-05-19 17:41:30 +02:00
parent f9ce24d2b7
commit fada96278b
2 changed files with 27 additions and 25 deletions

View File

@ -29,27 +29,28 @@
#endif #endif
typedef char LegoS8; typedef char LegoS8;
static_assert(sizeof(LegoS8) == 1, "Incorrect size");
typedef unsigned char LegoU8; typedef unsigned char LegoU8;
static_assert(sizeof(LegoU8) == 1, "Incorrect size");
typedef short LegoS16; typedef short LegoS16;
static_assert(sizeof(LegoS16) == 2, "Incorrect size");
typedef unsigned short LegoU16; typedef unsigned short LegoU16;
static_assert(sizeof(LegoU16) == 2, "Incorrect size");
typedef int LegoS32; typedef int LegoS32;
static_assert(sizeof(LegoS32) == 4, "Incorrect size");
typedef unsigned int LegoU32; typedef unsigned int LegoU32;
static_assert(sizeof(LegoU32) == 4, "Incorrect size");
typedef float LegoFloat; typedef float LegoFloat;
static_assert(sizeof(LegoFloat) == 4, "Incorrect size");
typedef char LegoChar; typedef char LegoChar;
static_assert(sizeof(LegoChar) == 1, "Incorrect size");
typedef LegoU8 LegoBool; typedef LegoU8 LegoBool;
static_assert(sizeof(LegoChar) == 1, "Incorrect size");
typedef LegoS32 LegoTime; typedef LegoS32 LegoTime;
static_assert(sizeof(LegoTime) == 4, "Incorrect size");
typedef LegoS32 LegoResult; typedef LegoS32 LegoResult;
static_assert(sizeof(LegoResult) == 4, "Incorrect size");
static_assert(sizeof(LegoS8) == 1, "sizeof(LegoS8) == 1");
static_assert(sizeof(LegoU8) == 1, "sizeof(LegoU8) == 1");
static_assert(sizeof(LegoS16) == 2, "sizeof(LegoS16) == 2");
static_assert(sizeof(LegoU16) == 2, "sizeof(LegoU16) == 2");
static_assert(sizeof(LegoS32) == 4, "sizeof(LegoS32) == 4");
static_assert(sizeof(LegoU32) == 4, "sizeof(LegoU32) == 4");
static_assert(sizeof(LegoFloat) == 4, "sizeof(LegoFloat) == 4");
static_assert(sizeof(LegoChar) == 1, "sizeof(LegoChar) == 1");
static_assert(sizeof(LegoChar) == 1, "sizeof(LegoChar) == 1");
static_assert(sizeof(LegoTime) == 4, "sizeof(LegoTime) == 4");
static_assert(sizeof(LegoResult) == 4, "sizeof(LegoResult) == 4");
#endif // __LEGOTYPES_H #endif // __LEGOTYPES_H

View File

@ -4,36 +4,22 @@
#include <stdint.h> #include <stdint.h>
typedef unsigned char MxU8; typedef unsigned char MxU8;
static_assert(sizeof(MxU8) == 1, "Incorrect size");
typedef signed char MxS8; typedef signed char MxS8;
static_assert(sizeof(MxS8) == 1, "Incorrect size");
typedef unsigned short MxU16; typedef unsigned short MxU16;
static_assert(sizeof(MxU16) == 2, "Incorrect size");
typedef signed short MxS16; typedef signed short MxS16;
static_assert(sizeof(MxS16) == 2, "Incorrect size");
typedef unsigned int MxU32; typedef unsigned int MxU32;
static_assert(sizeof(MxU32) == 4, "Incorrect size");
typedef signed int MxS32; typedef signed int MxS32;
static_assert(sizeof(MxS32) == 4, "Incorrect size");
typedef uint64_t MxU64; typedef uint64_t MxU64;
static_assert(sizeof(MxU64) == 8, "Incorrect size");
typedef int64_t MxS64; typedef int64_t MxS64;
static_assert(sizeof(MxS64) == 8, "Incorrect size");
typedef float MxFloat; typedef float MxFloat;
static_assert(sizeof(MxFloat) == 4, "Incorrect size");
typedef double MxDouble; typedef double MxDouble;
static_assert(sizeof(MxDouble) == 8, "Incorrect size");
typedef int MxLong; typedef int MxLong;
static_assert(sizeof(MxLong) == 4, "Incorrect size");
typedef unsigned int MxULong; typedef unsigned int MxULong;
static_assert(sizeof(MxULong) == 4, "Incorrect size");
typedef MxS32 MxTime; typedef MxS32 MxTime;
static_assert(sizeof(MxTime) == 4, "Incorrect size");
typedef MxLong MxResult; typedef MxLong MxResult;
static_assert(sizeof(MxResult) == 4, "Incorrect size");
#ifndef SUCCESS #ifndef SUCCESS
#define SUCCESS 0 #define SUCCESS 0
@ -76,4 +62,19 @@ typedef union {
// BYTE all; // ? // BYTE all; // ?
} FlagBitfield; } FlagBitfield;
static_assert(sizeof(MxU8) == 1, "sizeof(MxU8) == 1");
static_assert(sizeof(MxS8) == 1, "sizeof(MxS8) == 1");
static_assert(sizeof(MxU16) == 2, "sizeof(MxU16) == 2");
static_assert(sizeof(MxS16) == 2, "sizeof(MxS16) == 2");
static_assert(sizeof(MxU32) == 4, "sizeof(MxU32) == 4");
static_assert(sizeof(MxS32) == 4, "sizeof(MxS32) == 4");
static_assert(sizeof(MxU64) == 8, "sizeof(MxU64) == 8");
static_assert(sizeof(MxS64) == 8, "sizeof(MxS64) == 8");
static_assert(sizeof(MxFloat) == 4, "sizeof(MxFloat) == 4");
static_assert(sizeof(MxDouble) == 8, "sizeof(MxDouble) == 8");
static_assert(sizeof(MxLong) == 4, "sizeof(MxLong) == 4");
static_assert(sizeof(MxULong) == 4, "sizeof(MxULong) == 4");
static_assert(sizeof(MxTime) == 4, "sizeof(MxTime) == 4");
static_assert(sizeof(MxResult) == 4, "sizeof(MxResult) == 4");
#endif // MXTYPES_H #endif // MXTYPES_H