C interop
NanoC never needs to parse your headers. C functions, structs, macros and libraries are used as in C, and anything NanoC does not recognize passes through untouched.
Includes and libc
+stdlib
f main
p: ptr = malloc(128)
if p == NULL
< 1
free(p)
< 0#include <stdlib.h>
int main(void) {
void *p = malloc(128);
if (p == NULL) {
return 1;
}
free(p);
return 0;
}+stdio,stdlib includes standard headers (bare names add .h). Use + <header.h> or + "local.h" for explicit forms. Preprocessor chains are written with indentation instead of #endif; see the preprocessor lesson.
Raw C islands
@c takes an indented block, a balanced { ... } or a quoted string and copies it verbatim, bypassing expansion. Use it for function pointer declarators, attributes and compiler extensions.
@c {
static int apply(int (*fn)(int), int x) { return fn(x); }
}
f twice(x: i32) i32
x * 2
f main
`int (*fn)(int) = twice;`
apply(fn, 21) != 42
static int apply(int (*fn)(int), int x) { return fn(x); }
int twice(int x) {
return x * 2;
}
int main(void) {
int (*fn)(int) = twice;
return apply(fn, 21) != 42;
}Target: backtick inline C
The new core embeds C inline between backticks, without leaving the surrounding block.
f main
n := 21
`int doubled = n * 2;`
doubled != 42C++ and standards
--cpp emits C++17. --std c89|c99|c11|c17 selects output restrictions. User C must satisfy the chosen standard; NanoC does not rewrite it.