Janet 1.0.0-dev Documentation


Janet can be configured by editing the source header janetconf.h. To build Janet on certain platforms, disable features to save space, or integrated Janet into certain environments, editing this file may be required, although in most cases the default build of Janet should work.

Not all combinations of flags are guaranteed to work, although in most cases they should. You should should probably run the test suite on a particular set of flags to verify that they can work together.


#define JANET_MAJOR 1 ### #define JANET_MINOR 2 ### #define JANET_PATCH 3 ### #define JANET_EXTRA "-dev" ### #define JANET_VERSION "1.2.3-dev"

Use these defines to set the janet version. The major, minor, and patch values must be in sync with the version string.

#define JANET_BUILD "my-local-build"

Set this to any string such as "local" to set what value janet/build will have at runtime. By default, is set to a git commit hash.


Define this if you know the interpreter will only run in a single threaded program or context. When this define is set, global Janet state will use normal global C variables rather than thread local variables.


Define this to disable loading of dynamic modules via the native function. This also lets Janet run on platforms without dlopen or Windows, as well as letting Janet be compiled without linking to -ldl on Posix.


Define this to disable the functions asm and disasm in the core library. The assembler is not needed to run most programs, can is useful for inspecting functions, debugging, and writing a compiler for the Janet abstract machine.

#define JANET_NO_PEG

Define this to disable the peg module. The core Janet library should work without the peg module, and be slightly smaller, but this flag is not recommended as the peg module itself is actually quite small. This disables the functions peg/match and peg/compile.


Define this to disable the tarray module. Typed arrays are an interface besides buffers for interacting with binary data in a structured manner. The core Janet library does not use them, but they could be used by native modules, especially bindings to scientific or numerical libraries.


Define this to disable the `int` module. The `int` module contains abstract types and methods for integers that cannot fit in a Janet number. The only integer types currently support are signed and unsigned 64 bit integers. The current implementation makes this module quite large.


Define this to compile the `os` module with only the bar minimum needed for boot.janet. This is just os/exit, os/getenv, and os/which. All other functions in the os module will be disabled.

#define JANET_API __attribute__((visibility ("default")))

Set this define to change how Janet symbols in the core library are exported. If using dynamic modules, all symbols in the Janet core library must be publicly visible. It is not recommended to change this unless you are dramatically changing the build system.

#define JANET_OUT_OF_MEMORY do { printf("oops!\n"); exit(1); } while (0)

Set this macro to decide what Janet will do if it runs out of memory. Be default, the program will print an error message and exit, but you may want Janet to clean up resources or longjmp somewhere if using Janet in a larger application.


Set this to a positive integer to prevent recursive functions in C from causing a segfault via a stack overflow. All recursive functions in Janet use a counter to keep them from overflowing the stack, and will error if the recursion gets too deep. Use this to set how many recursions are allowed before errors. Functions that have such a limitation are compile and marshal.


Set this define to determine how many tables to recursively check for prototypes before throwing an error. This is needed as it is easily possible to create tables that form a cyclic prototype loop, which would otherwise stall the VM if we do not detect it.


Set this define to limit the number of times a form can be macro expanded. This is also to limit the damage that could be caused by a recursive macro, although even simple recursive macros can stall the VM with even modest recursion limits.

#define JANET_STACK_MAX 16384

Set the default maximum size of a fiber's stack in number of Janet values. This means that a max stack of 1000 will be able to store approximately 1000 Janet values on the stack, NOT that the fiber can hold 1000 stack frames. This can also be changed on a per fiber basis at runtime, although each new fiber will have stack maximum set to this value by default. Setting a maximum stack size per stack is only useful for more quickly detecting stack overflow issues, but each fiber stack starts with a minimum amount of memory and only expands as needed. This means that setting this value to a lower value will not make Janet use less memory.


Internally, Janet uses a technique called nanboxing to make each Janet value take less memory and allow the VM to be faster (although Janet mainly uses the technique for the first reason). This technique, however, is not valid C of any kind, and will only work correctly on some architectures. Many 64 bit architectures will have trouble with the nanboxing code, so it is by default turned of on 64 bit, non x86 architectures. However, one may also want to turn off nanboxing for other reasons, so this flag is exposed for that reason. If an unsupported architecture mistakenly tries to use nanboxing, this could be considered a bug and the platform detection macros in janet.h should be updated to disable nanboxing for that platform.