-
Notifications
You must be signed in to change notification settings - Fork 0
Multi file Projects
Derek Snider edited this page May 19, 2026
·
3 revisions
Single-file programs are the default in madc. For larger projects, use #include to compose multiple source files.
Create a top-level file named after your application that #includes the rest in order, with int main() last:
// smaug.mad
#include "config.mad"
#include "mud.mad"
#include "tables.mad"
#include "comm.mad"
// ... other source files ...
#include "main.mad" // contains int main()Run the whole project:
madc smaug.mad-
#include "file.mad"— resolves relative to the including file -
#include <stdio.h>— checks embedded headers first, then filesystem - Nested includes are supported
- Repeated includes of the same file are automatically skipped within a single compile
- All included code shares the same global scope
myproject/
myproject.mad # top-level entry point
config.mad # configuration and constants
types.mad # struct definitions
utils.mad # utility functions
main.mad # int main()
// myproject.mad
#include "config.mad"
#include "types.mad"
#include "utils.mad"
#include "main.mad"madc myproject.madmadc -o myproject myproject.mad
./myprojectThe entire project compiles to a single native ELF binary.
-
Preprocessor —
#define,#ifdef,#include,#load - Getting Started — if you haven't set up madc yet
- ← Back to Home