How to Run GCC-XML

gccxml [options] <input-file> -fxml=<output-file>
GCC-XML parses a C++ source file as it is seen by the compiler when it is built. An easy-to-parse XML representation of the class, function, and namespace declarations is dumped to a specified file. Full C preprocessing transforms the file into a C++ translation unit as seen by the compiler. This means that GCC-XML should make use of the same standard library and other header files as the compiler. GCC-XML can be configured to simulate any of several popular compilers.

Command-line Options

The following options are available for running GCC-XML: Other flags, such as -I and -D, are passed on to the patched GCC C++ parser executable.

Configuration Settings

GCC-XML is designed to simulate a compiler's parser while reading C++ source code. Some configuration settings are needed to determine how to simulate a particular compiler of the user's choice. The following settings can be used to configure GCC-XML: There are several means by which these settings are configured. They are listed here in order of precedence (highest first): Most users should not have to adjust the defaults for these settings. There is a default GCCXML_CONFIG file provided in the support library directory after installation. It configures GCC-XML to simulate the compiler that was used to build it.

Supported Compilers

GCC-XML can simulate any of the following compilers: The following extra C preprocessor definitions are provided: Advanced users can simulate other compilers by manually configuring the GCCXML_FLAGS setting. Contact the mailing list for help.

C++ Meta Information

GCC-XML has added a new attribute to the legal set of C/C++ attributes. The attribute is used to attach meta information to C/C++ source code, which will then appear in the XML output. The syntax for declaring an attribute is as follows: The XML output for the code element that is tagged with the attribute will then contain the following: The 'gccxml' attribute can be applied to any declaration including structs, classes, fields, parameters, methods, functions, variables, and typedefs. The only exception is that GCC's handling of the '__attribute' language element is currently broken for enumerations and constructors with an inlined body. The 'gccxml' attribute can be used any number of times on a given declaration. As an example of how this attribute can be used to attach meta information to C++ declarations, consider the following macro: Now a method declaration can be written as follows: Using the 'gccxml' attribute enables meta information to be included directly within C++ source code, without the need for a custom parser to extract the meta information. The 'gccxml' attribute is provided for convenience only - there is no guarantee that future versions of GCC will accept the '__attribute' language element in a bug-free manner.