LinuxCommandLibrary

castxml

TLDR

Generate XML from C++ header

$ castxml --castxml-output=1 [header.hpp] -o [output.xml]
copy
Generate gccxml-compatible output
$ castxml --castxml-gccxml [header.hpp] -o [output.xml]
copy
Configure for GNU compiler
$ castxml --castxml-cc-gnu [g++] [header.hpp] -o [output.xml]
copy
Start traversal at specific declaration
$ castxml --castxml-start [ClassName] [header.hpp] -o [output.xml]
copy
Include path and defines
$ castxml -I[/include/path] -D[MACRO] [header.hpp] -o [output.xml]
copy

SYNOPSIS

castxml [options] inputfile_

DESCRIPTION

castxml creates an XML representation of C++ declarations from source files. It parses C-family languages using Clang and outputs an abstract syntax tree in XML format.
The tool is commonly used for generating language bindings and code analysis.

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++ codebases
Documentation
Extract API information

CAVEATS

Output format depends on selected option. GCCXML format provided for legacy compatibility. Use with pygccxml for Python-based analysis.

SEE ALSO

clang(1), g++(1)

Copied to clipboard