castxml
generate XML descriptions of C/C++ declarations
TLDR
Generate XML from C++ header
SYNOPSIS
castxml [options] inputfile_
DESCRIPTION
castxml creates an XML representation of C and C++ declarations from source files. It uses the Clang compiler frontend to parse C-family source code and produces a structured XML output describing types, functions, classes, and other declarations.
The tool is commonly used as a foundation for generating language bindings, enabling projects like pygccxml to automatically create Python wrappers for C++ libraries. It also serves as a code analysis backend where machine-readable representations of header files are needed.
CastXML was created as a replacement for the deprecated GCC-XML tool, providing a modern Clang-based alternative with compatible output formats for backward compatibility.
PARAMETERS
--castxml-output=version
Generate castxml-format output (version must be '1')--castxml-gccxml
Generate gccxml-compatible output format--castxml-cc-gnu compiler
Configure preprocessor/target for GNU compiler--castxml-cc-msvc compiler
Configure preprocessor/target for MSVC compiler--castxml-cc-gnu-c compiler
Configure for GNU C compiler--castxml-cc-msvc-c compiler
Configure for MSVC C compiler--castxml-start name
Start AST traversal at named declaration-o file
Output file path-I path
Add include search path-D macro
Define preprocessor macro-std=standard
C++ standard (c++11, c++14, c++17, etc.)
USE CASES
Language bindings
Generate bindings for Python, Rust, etc.Code analysis
Parse and analyze C++ codebasesDocumentation
Extract API information
CAVEATS
Output format depends on selected option. GCCXML format provided for legacy compatibility. Use with pygccxml for Python-based analysis.
