mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Add a static_assert() polyfill to platform.h
Part of P0198, funded by Lmocinemod and Ember2528.
This commit is contained in:
parent
16aba1bc9a
commit
8fce97ea1c
|
@ -31,6 +31,11 @@ typedef void ( far pascal * far farfunc_t_far)(void);
|
|||
#endif
|
||||
/// ----------
|
||||
|
||||
// Message-less static_assert() wasn't available until C++17
|
||||
#if (__cplusplus < 201703L)
|
||||
#define static_assert(condition) ((void)sizeof(char[1 - 2*!(condition)]))
|
||||
#endif
|
||||
|
||||
// Both Turbo C++ and master.lib use uint16_t for segment values throughout
|
||||
// their APIs instead of the more sensible void __seg*. Maybe, integer
|
||||
// arithmetic on segment values was widely considered more important than
|
||||
|
|
|
@ -30,7 +30,7 @@ void near b6balls_add(void)
|
|||
|
||||
void near b6balls_update(void)
|
||||
{
|
||||
CUSTOM_VERIFY(b6ball_t, B6BALL_COUNT);
|
||||
custom_assert_count(b6ball_t, B6BALL_COUNT);
|
||||
|
||||
b6ball_t near *p;
|
||||
int i;
|
||||
|
|
|
@ -20,8 +20,8 @@ typedef struct {
|
|||
|
||||
extern custom_t custom_entities[CUSTOM_COUNT];
|
||||
|
||||
#define CUSTOM_VERIFY(derived_type, derived_count) \
|
||||
((void)sizeof(char[1 - 2*!!( \
|
||||
(sizeof(derived_type) * derived_count) \
|
||||
> (sizeof(custom_t) * CUSTOM_COUNT) \
|
||||
)]))
|
||||
#define custom_assert_count(derived_type, derived_count) \
|
||||
static_assert( \
|
||||
(sizeof(derived_type) * derived_count) <= \
|
||||
(sizeof(custom_t) * CUSTOM_COUNT) \
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue