zig translate-c <files...>

Convert C code to Zig code

Arguments

NameDescription
filesfilepaths

Options

NameDescription
-h, --helpPrint help and exit
--watchEnable compiler REPL
--color <arg>Enable or disable colored message
-femit-bin(default) Output machine code
-fno-emit-binDo not output machine code
-femit-asmOutput .s (assembly code)
-fno-emit-asm(default) Do not output .s (assembly code)
-femit-llvm-irProduce a .ll file with LLVM IR (requires LLVM extensions)
-fno-emit-llvm-ir(default) Do not produce a .ll file with LLVM IR
-femit-llvm-bcProduce a LLVM module as a .bc file (requires LLVM extensions)
-fno-emit-llvm-bc(default) Do not produce a LLVM module as a .bc file
-femit-hGenerate a C header file (.h)
-fno-emit-h(default) Do not generate a C header file (.h)
-femit-docsCreate a docs/ dir with html documentation
-fno-emit-docs(default) Do not produce docs/ dir with html documentation
-femit-analysisWrite analysis JSON file with type information
-fno-emit-analysis(default) Do not write analysis JSON file with type information
-femit-implib(default) Produce an import .lib when building a Windows DLL
-fno-emit-implibDo not produce an import .lib when building a Windows DLL
--show-builtinOutput the source of @import("builtin") then exit
--cache-dir <arg>Override path to local Zig cache directory
--global-cache-dir <arg>Override path to global Zig cache directory
--zig-lib-dir <arg>Override path to Zig lib directory
--enable-cacheOutput to cache directory; print path to stdout
-target<arch><sub>-<os>-<abi> see the targets command
-mcpuSpecify target CPU and feature set
-mcmodel <arg>Limit range of code and data virtual addresses
-mred-zoneForce-enable the "red-zone"
-mnored-zoneForce-disable the "red-zone"
-fomit-frame-pointerOmit the stack frame pointer
-fno-omit-frame-pointerStore the stack frame pointer
-mexec-model(WASI) Execution model
--nameOverride root name (not a file path)
-O <mode>Choose what to optimize for
--pkg-begin <name> <path>Make pkg available to import and push current pkg
--pkg-endPop current pkg
--main-pkg-path <path>Set the directory of the root package
-fPICForce-enable Position Independent Code
-fno-PICForce-disable Position Independent Code
-fPIEForce-enable Position Independent Executable
-fno-PIEForce-disable Position Independent Executable
-fltoForce-enable Link Time Optimization (requires LLVM extensions)
-fno-ltoForce-disable Link Time Optimization
-fstack-checkEnable stack probing in unsafe builds
-fno-stack-checkDisable stack probing in unsafe builds
-fstack-protectorEnable stack protection in unsafe builds
--fno-stack-protectorDisable stack protection in unsafe builds
-fsanitize-cEnable C undefined behavior detection in unsafe builds
-fno-sanitize-cDisable C undefined behavior detection in safe builds
-fvalgrindInclude valgrind client requests in release builds
-fno-valgrindOmit valgrind client requests in debug builds
-fsanitize-threadEnable Thread Sanitizer
-fno-sanitize-threadDisable Thread Sanitizer
-fdll-export-fnsMark exported functions as DLL exports (Windows)
-fno-dll-export-fnsForce-disable marking exported functions as DLL exports
-funwind-tablesAlways produce unwind table entries for all functions
-fno-unwind-tablesNever produce unwind table entries
-fLLVMForce using LLVM as the codegen backend
-fno-LLVMPrevent using LLVM as the codegen backend
-fClangForce using Clang as the C/C++ compilation backend
-fno-ClangPrevent using Clang as the C/C++ compilation backend
-fstage1Force using bootstrap compiler as the codegen backend
-fno-stage1Prevent using bootstrap compiler as the codegen backend
-freference-traceHow many lines of reference trace should be shown per compile error
-fno-reference-traceDisable reference trace
-fsingle-threadedCode assumes there is only one thread
-fno-single-threadedCode may not assume there is only one thread
-fbuiltinEnable implicit builtin knowledge of functions
-fno-builtinDisable implicit builtin knowledge of functions
-ffunction-sectionsPlaces each function in a separate section
-fno-function-sectionsAll functions go into same section
-fstripOmit debug symbols
-fno-stripKeep debug symbols
-ofmt <mode>Override target object format
-idirafter <dir>Add directory to AFTER include search path
-isystem <dir>Add directory to SYSTEM include search path
-IAdd directory to include search path
-DDefine C [macro] to [value] (1 if [value] omitted)
--libc <file>Provide a file which specifies libc paths
-cflagsSet extra flags for the next positional C source files
-l, --library <lib>Link against system library (only if actually used)
-needed-l, --needed-library <lib>Link against system library (even if unused)
-L, --library-directory <d>Add a directory to the library search path
-T, --script <script>Use a custom linker script
--version-script <path>Provide a version .map file
--dynamic-linker <path>Set the dynamic interpreter path (usually ld.so)
--sysroot <path>Set the system root directory (usually /)
--version <ver>Dynamic library semver
--entry <name>Set the entrypoint symbol name
-fsonameOverride the default SONAME value
-fno-sonameDisable emitting a SONAME
-fLLDForce using LLD as the linker
-fno-LLDPrevent using LLD as the linker
-fcompiler-rtAlways include compiler-rt symbols in output
-fno-compiler-rtPrevent including compiler-rt symbols in output
-rdynamicAdd all symbols to the dynamic symbol table
-rpath <path>Add directory to the runtime library search path
-feach-lib-rpathEnsure adding rpath for each used dynamic library
-fno-each-lib-rpathPrevent adding rpath for each used dynamic library
-fallow-shlib-undefinedAllows undefined symbols in shared libraries
-fno-allow-shlib-undefinedDisallows undefined symbols in shared libraries
-fbuild-idHelps coordinate stripped binaries with debug symbols
-fno-build-id(default) Saves a bit of time linking
--eh-frame-hdrEnable C++ exception handling by passing --eh-frame-hdr to linker
--emit-relocsEnable output of relocation sections for post build tools
-z <arg>Set linker extension flags
-dynamicForce output to be dynamically linked
-staticForce output to be statically linked
-BsymbolicBind global references locally
--compress-debug-sections <e>Debug section compression settings
--gc-sectionsForce removal of functions and data that are unreachable by the entry point or exported symbols
--no-gc-sectionsDon't force removal of unreachable functions and data
--subsystem <subsystem>(Windows) /SUBSYSTEM:<subsystem> to the linker
--stack <size>Override default stack size
--image-base <addr>Set base address for executable image
-weak-l, -weak_library <lib>(Darwin) link against system library and mark it and all referenced symbols as weak
-framework <name>(Darwin) link against framework
-needed_framework <name>(Darwin) link against framework (even if unused)
-needed_library <lib>(Darwin) link against framework (even if unused)
-weak_framework <name>(Darwin) link against framework and mark it and all referenced symbols as weak
-F <dir>(Darwin) add search path for frameworks
-install_name(Darwin) add dylib's install name
--entitlements <path>(Darwin) add path to entitlements file for embedding in code signature
-pagezero_size <value>(Darwin) size of the __PAGEZERO segment in hexadecimal notation
-search_paths_first(Darwin) search each dir in library search paths for `libx.dylib` then `libx.a`
-search_dylibs_first(Darwin) search `libx.dylib` in each dir in library search paths, then `libx.a`
-headerpad <value>(Darwin) set minimum space for future expansion of the load commands in hexadecimal notation
-headerpad_max_install_names(Darwin) set enough space as if all paths were MAXPATHLEN
-dead_strip(Darwin) remove functions and data that are unreachable by the entry point or exported symbols
-dead_strip_dylibs(Darwin) remove dylibs that are unreachable by the entry point or exported symbols
--import-memory(WebAssembly) import memory from the environment
--import-table(WebAssembly) import function table from the host environment
--export-table(WebAssembly) export function table to the host environment
--initial-memory(WebAssembly) initial size of the linear memory
--max-memory(WebAssembly) maximum size of the linear memory
--shared-memory(WebAssembly) use shared linear memory
--global-base(WebAssembly) where to start to place global data
--export(WebAssembly) Force a symbol to be exported
--test-filter <filter>Skip tests that do not match filter
--test-name-prefix <text>Add prefix to all tests
--test-cmd <arg>Specify test execution command one arg at a time
--test-cmd-binAppends test binary path to test cmd args
--test-evented-ioRuns the test in evented I/O mode
--test-no-execCompiles test binary without running it
-ftime-reportPrint timing diagnostics
-fstack-reportPrint stack size diagnostics
--verbose-linkDisplay linker invocations
--verbose-ccDisplay linker invocations
--verbose-airEnable compiler debug output for Zig AIR
--verbose-llvm-irEnable compiler debug output for LLVM IR
--verbose-cimportEnable compiler debug output for C imports
--verbose-llvm-cpu-featuresEnable compiler debug output for LLVM CPU features
--debug-log <scope>Enable printing debug/info log messages for scope
--debug-compile-errorsCrash with helpful diagnostics at the first compile error
--debug-link-snapshotEnable dumping of the linker's state in JSON format