Skip to content

Category Tiko Compiler Define

Paul Squires edited this page Oct 22, 2026 · 7 revisions

Home › All Categories › TIKO_COMPILER

TIKO_COMPILER

tiko defines __TIKO_COMPILER__, always 1:

#ifdef __TIKO_COMPILER__
	print "tiko"; __TIKO_COMPILER__      '' tiko prints: tiko 1
#else
	print "not tiko"                     '' another compiler prints this
#endif

Guarding tiko-only code

Test it with #ifdef or defined( ), so that a compiler which does not define it takes the other branch rather than stopping:

#import "std/containers"
#ifdef __TIKO_COMPILER__
	dim names as containers.Array( of ustring )  '' tiko builds this
#else
	dim names(0 to 63) as string         '' another compiler builds this
#endif

Comparing the VALUE is not a portable guard: #if __TIKO_COMPILER__ = 1 fails on a compiler that does not define the name.

__FB_MIN_VERSION__ is not defined by tiko, so #if __FB_MIN_VERSION__( 1, 20, 0 ) is an error under tiko:

error TKO0308: invalid expression in '#if'

Which operating system

tiko defines one TIKO_OS_ name for the target being built, always 1:

Target Defined Not defined
windows-x86_64 TIKO_OS_WINDOWS TIKO_OS_LINUX, TIKO_OS_MACOS
linux-x86_64 TIKO_OS_LINUX TIKO_OS_WINDOWS, TIKO_OS_MACOS
macos-arm64 TIKO_OS_MACOS TIKO_OS_WINDOWS, TIKO_OS_LINUX

The name follows -target, not the machine running the compiler, so -target linux-x86_64 on Windows takes the Linux branch:

#ifdef TIKO_OS_WINDOWS
	print "windows"; TIKO_OS_WINDOWS     '' windows-x86_64 prints: windows 1
#elseif defined( TIKO_OS_LINUX )
	print "linux"; TIKO_OS_LINUX         '' linux-x86_64 prints: linux 1
#elseif defined( TIKO_OS_MACOS )
	print "macos"; TIKO_OS_MACOS         '' macos-arm64 prints: macos 1
#else
	print "other"
#endif

Exactly one of the three is defined on every target.

What tiko defines

Define tiko
__TIKO_COMPILER__ 1
__TIKO_VERSION__ "0.1.0-dev"
__FB_VERSION__ "1.20.0"
__FB_SIGNATURE__ "tiko-lang"
__FB_BACKEND__ "llvm"
__FB_MIN_VERSION__ not defined
TIKO_OS_WINDOWS 1 on windows-x86_64, otherwise not defined
TIKO_OS_LINUX 1 on linux-x86_64, otherwise not defined
TIKO_OS_MACOS 1 on macos-arm64, otherwise not defined
TIKO_ARCH_X86_64 1 on windows-x86_64 and linux-x86_64, otherwise not defined
TIKO_ARCH_ARM64 1 on macos-arm64, otherwise not defined

__TIKO_COMPILER__ says which compiler is building; __TIKO_VERSION__ says which version of it. Neither says which features it has, so code that must build with several versions still tests more than one symbol.

tests/pp/tiko-compiler-define.test holds the define and its value; tests/pp/tiko-target-defines.test holds the TIKO_OS_ and TIKO_ARCH_ names on each target.

See also


Category: TIKO_COMPILER Kind: intrinsic define

Clone this wiki locally