Include actor.h from controller.h so the header compiles on its own

controller.h declares three handler pointers taking an akgl_Actor * and
included nothing that declares that type, so any translation unit reaching
for it before akgl/actor.h failed with "unknown type name 'akgl_Actor'".
src/controller.c never noticed because it includes akgl/game.h first, and
tests/controller.c carried a comment explaining the workaround.

Included rather than forward-declared: akgl_Actor is a typedef of a named
struct and repeating a typedef is C11, not C99. It closes no cycle --
actor.h reaches only types.h and character.h.

tests/headers.c is a whole suite for one #include on purpose. A second
#include after the first proves nothing about the second, because by then
the first has dragged its dependencies in; covering another header means
another file shaped like this one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-31 12:53:09 -04:00
parent a3eada1b3f
commit 57bf1c7649
4 changed files with 46 additions and 2 deletions

View File

@@ -13,8 +13,8 @@
#include <akerror.h>
#include <akgl/error.h>
// akgl/controller.h uses akgl_Actor without declaring it, so actor.h has to
// come first, the same way src/controller.c reaches it through akgl/game.h.
// For the akgl_Actor_cmhf_* handlers these tests bind. akgl/controller.h pulls
// actor.h in for itself now; tests/headers.c is what keeps it doing so.
#include <akgl/actor.h>
#include <akgl/character.h>
#include <akgl/game.h>