|
Banjo API 1.0.0-rc.2
Low-level C99 game development API
|
Macros | |
| #define | BJ_NO_AUTOMAIN |
| #define | BJ_AUTOMAIN |
Functions | |
| int | bj_main (int argc, char *argv[]) |
| int | bj_call_main (int argc, char *argv[], int(*function)(int argc, char *argv[])) |
Write a regular int main(...), include <banjo/main.h>, and Banjo provides whatever platform entry point the target actually wants.
On Linux and macOS, int main(int argc, char* argv[]) is the entry point as you wrote it. On Windows, the OS may want WinMain for GUI programs, and argv arrives in the system locale rather than UTF-8. On Emscripten the JavaScript host calls main and then expects you to register a per-tick callback. Writing one int main(...) and expecting it to work on every platform needs a little glue.
<banjo/main.h> is that glue for standard-mode programs: short programs that fit in one main body, do their work, and return. The header renames your main to bj_main (via #define main bj_main) and, on platforms that need it, emits a real main / WinMain that converts arguments to UTF-8 and forwards to your bj_main.
For long-running interactive programs (windows, animation, audio), use Application instead. Its callback model handles the platforms that own the run loop (Emscripten, future iOS) without per-platform #ifdefs in user code.
Define BJ_NO_AUTOMAIN before including the header to keep main as you wrote it; Banjo emits no wrapper.
| #define BJ_AUTOMAIN |
| #define BJ_NO_AUTOMAIN |
Opt out of Banjo's automatic main shim.
Define this macro before including <banjo/main.h> to keep main() exactly as you wrote it. Banjo will not emit any wrapper. Useful when you have your own platform-specific entry handling.
|
extern |
Forward into the user-supplied bj_main from a platform stub.
Called by the platform entry point that BJ_AUTOMAIN emits. On Windows this converts the UTF-16 command line into a UTF-8 argv before invoking function. On other platforms it forwards the argv it was given.
| argc | Argument count. |
| argv | Argument vector (may be ignored on Windows). |
| function | The user's main, typically bj_main. |
function.
|
extern |
The user's main(), after Banjo renames it.
You write int main(int argc, char* argv[]); the header's #define main bj_main rewrites it into this symbol. Banjo's emitted platform stub then forwards to it through bj_call_main.