43 lines
1.6 KiB
C
43 lines
1.6 KiB
C
|
|
/**
|
||
|
|
* @file header_pool_override.c
|
||
|
|
* @brief Checks that the compile-time pool-size overrides in heap.h actually fire.
|
||
|
|
*
|
||
|
|
* `heap.h` wraps every `AKGL_MAX_HEAP_*` ceiling in an `#ifndef` so a game that
|
||
|
|
* needs more actors can define its own before including it. That mechanism was
|
||
|
|
* dead until 0.5.0: `actor.h`, `sprite.h` and `character.h` defined the same
|
||
|
|
* four unconditionally, and `heap.h` includes all three *above* its own
|
||
|
|
* `#ifndef` block, so whichever landed first won and the guard never fired. The
|
||
|
|
* override was documented, and did nothing.
|
||
|
|
*
|
||
|
|
* The assertion is the compile. Nothing here links against the pools -- it
|
||
|
|
* cannot, because the library was built with the default ceilings and this
|
||
|
|
* translation unit deliberately disagrees with it. That disagreement is the
|
||
|
|
* documented consequence of overriding a ceiling, not something this file is
|
||
|
|
* working around: the arrays are sized at compile time, so the library and
|
||
|
|
* everything linking it have to agree.
|
||
|
|
*/
|
||
|
|
|
||
|
|
#define AKGL_MAX_HEAP_ACTOR 128
|
||
|
|
#define AKGL_MAX_HEAP_STRING 512
|
||
|
|
|
||
|
|
#include <akgl/heap.h>
|
||
|
|
|
||
|
|
#if AKGL_MAX_HEAP_ACTOR != 128
|
||
|
|
#error "heap.h overrode a caller's AKGL_MAX_HEAP_ACTOR; the #ifndef guard is dead again"
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#if AKGL_MAX_HEAP_STRING != 512
|
||
|
|
#error "heap.h overrode a caller's AKGL_MAX_HEAP_STRING; the #ifndef guard is dead again"
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* The derived ceilings have to follow the override rather than a stale literal. */
|
||
|
|
#if AKGL_MAX_HEAP_SPRITE != (128 * 16)
|
||
|
|
#error "AKGL_MAX_HEAP_SPRITE no longer derives from AKGL_MAX_HEAP_ACTOR"
|
||
|
|
#endif
|
||
|
|
|
||
|
|
int akgl_header_selftest_pool_override(void);
|
||
|
|
int akgl_header_selftest_pool_override(void)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|