TCCState).
Creating a compilation context
tcc_new
Creates a new TCC compilation context.Pointer to the newly created compilation context, or
NULL if allocation fails.Destroying a compilation context
tcc_delete
Frees a TCC compilation context and all associated resources.The compilation context to free.
Setting output type
tcc_set_output_type
Sets the output type for the compilation. Must be called before any compilation.The compilation context.
The type of output to generate. One of:
TCC_OUTPUT_MEMORY(1) - Run code in memoryTCC_OUTPUT_EXE(2) - Executable fileTCC_OUTPUT_DLL(4) - Dynamic libraryTCC_OUTPUT_OBJ(3) - Object fileTCC_OUTPUT_PREPROCESS(5) - Only preprocess
Returns 0 on success, -1 on error.
Configuring paths
tcc_set_lib_path
Sets the path where TCC will look for its internal libraries and include files.The compilation context.
Path to the TCC library directory (typically contains
include/ and lib/).tcc_add_include_path
Adds a directory to the include file search path.The compilation context.
Path to add to the include search path.
Returns 0 on success.
tcc_add_sysinclude_path
Adds a system include path to the default system include paths.The compilation context.
System include path to add.
Returns 0 on success.
Setting options
tcc_set_options
Sets compiler options as if passed on the command line. Multiple calls are supported.The compilation context.
Command-line style options (e.g., “-Wall -O2”).
Returns 0 on success, -1 on error.
Error handling
tcc_set_error_func
Sets a custom error and warning callback.The compilation context.
User data pointer passed to the error callback (can be
NULL).Callback function for errors and warnings. If
NULL, errors are printed to stderr.Preprocessor configuration
tcc_define_symbol
Defines a preprocessor symbol.The compilation context.
Symbol name. Can be “sym=val” form, or just “sym”.
Symbol value. If
NULL and sym doesn’t contain ’=’, defaults to “1”.tcc_undefine_symbol
Undefines a preprocessor symbol.The compilation context.
Symbol name to undefine.
Custom memory allocator
tcc_set_realloc
Sets a custom memory allocator for all TCC allocations. This is a global setting.Custom realloc-style function. If
NULL, uses the default allocator.
The function should free memory when size is 0.