Preprocessor
The GPC3 compiler supports common preprocessor directives for constants, shared include files, and compile-time switches.
Defines
gpc
#define TEST_HOLD_MS 100
#define STICK_SCALE 1.20
main {
if (event_active(BUTTON_11)) {
combo_restart(OutputTest);
}
}
combo OutputTest {
set_val(BUTTON_15, 100);
wait(TEST_HOLD_MS);
set_val(BUTTON_15, 0);
}Compatible GPC scripts can also use the assignment-style form:
gpc
define FIRE_TIME = 45;Conditional Blocks
gpc
#define ENABLE_DEBUG
main {
#ifdef ENABLE_DEBUG
if (event_active(BUTTON_11)) {
printf("Debug toggle");
}
#endif
}Includes
gpc
#include "shared_settings.inc"
#include <keyboard.gph>
#include <mouse.gph>
#include <remapper.gph>Use quoted includes for shared constants and small helper functions that are reused across scripts. Use angle-bracket includes for the built-in keyboard.gph, mouse.gph, and remapper.gph headers.
Supported Directives
| Directive | Use |
|---|---|
#define |
Create a compile-time value or macro |
#undef |
Remove a defined value |
#include |
Include another source file |
#if |
Compile when an expression is true |
#ifdef |
Compile when a name is defined |
#ifndef |
Compile when a name is not defined |
#else |
Alternate conditional branch |
#endif |
End a conditional block |
Notes
- Keep includes small and readable.
- Prefer simple constants over clever macros.
- Use conditional blocks for debug logging or feature variants.