← 返回命令列表

Linux command

castxml 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Generate XML from C++ header

castxml --castxml-output=1 [header.hpp] -o [output.xml]

Generate gccxml-compatible output

castxml --castxml-gccxml [header.hpp] -o [output.xml]

Configure for GNU compiler

castxml --castxml-cc-gnu [g++] [header.hpp] -o [output.xml]

Start traversal at specific declaration

castxml --castxml-start [ClassName] [header.hpp] -o [output.xml]

Include path and defines

castxml -I[/include/path] -D[MACRO] [header.hpp] -o [output.xml]

说明

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.

参数

--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.)

FAQ

What is the castxml command used for?

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.

How do I run a basic castxml example?

Run `castxml --castxml-output=1 [header.hpp] -o [output.xml]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --castxml-output=_version_ do in castxml?

Generate castxml-format output (version must be '1')