Directives
The @ directives: code chosen at build time, and the build's settings.
Examples: res\examples\language\directives holds small, commented programs for this page's features, each listing the output it prints; run one with adam build <file> -r.
Conditional code
The conditional directives, @define, @undef, @ifdef, @ifndef, @elseif, @else and @endif, may stand anywhere, and the compiler evaluates them.
module exe directives_define;
@define VERBOSE
begin
@ifdef VERBOSE
println("verbose build");
@else
println("quiet build");
@endif
@ifdef DEBUG
println("debug build");
@else
println("release build");
@endif
@ifdef RELEASE_FAST
println("level fast");
@endif
end.
verbose build
release build
level fast
Predefined symbols
A build defines ADAM; BUILD_EXE, BUILD_DLL, BUILD_LIB or BUILD_UNIT from the file's kind; and TARGET_ names for its target's parts (TARGET_X86_64, TARGET_WINDOWS or TARGET_LINUX, TARGET_GNU), its whole triple (TARGET_X86_64_WINDOWS_GNU) and TARGET_64BIT for a 64-bit pointer. A debug build defines DEBUG, and a release build RELEASE and RELEASE_<level> (RELEASE_FAST for -opt fast).
module exe directives_target;
begin
// The branch for the build's own target is compiled; the other is left out
@ifdef TARGET_X86_64_WINDOWS_GNU
println("Built for x86_64-windows-gnu");
@else
println("Built for x86_64-linux-gnu");
@endif
end.
Built for x86_64-windows-gnu
Built for x86_64-linux-gnu
Build settings
A build directive stands only in the module's directive prologue, right after module ..;; anywhere else it is an error.
@optimizetakes debug, safe, fast or small, and@targeta triple; each stands at most once in the main module, andadam -optandadam -twin over them.@linklibraryand@addlibrarypathadd a library and a folder to search, found the way anexternalclause's library is.@addresdata "KEY" "PATH";builds a file into the binary under its key, the same on every target, and the program reads it back by key at run time.- Version info is stamped only with
@addverinfo on;, from@vimajor,@viminor,@vipatchand the@vitexts;@exeicongives the exe its icon. @outputpathsets the build's output folder, andadam -owins over it.
Messages and breakpoints
@message hint|warn|error|fatal "text"; reports its text at its line, and @breakpoint; marks its line for the debugger; both are also statements. The Directives lists every directive.