C Python C++
Pull request Compare This branch is 33 commits ahead, 33 commits behind gccxml:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This GCC plugin gives GCC the power to dump an XML definition of C++ source code.

This is a fork of the GCCXML repository, which aims to provide the same functionality as the original driver, but without the need to compile a whole new C++ compiler. Instead, this hooks in to your local installation of GCC and is loaded as a plugin, using the GCC plugin API.

So there's no need for compiler Support headers, making the built package much more light weight and quicker to build than the original version.

These "benefits" do come at a slight cost, however. Firstly, the plugin version will be unable to emulate other compilers, as the original GCC-XML claims to do. It will also only work with GCC, to which the plugin API is unique.

Finally, I haven't reimplemented the gccxml driver in C. Instead, gcc needs to be given some pretty horrendous arguments to load it (see Running).

This style of command line arguments will obviously be incompatible with any tool that depends on gccxml's command line API. So, a Python2 script was written, gccxml_plugin, which aims to provide the exact same command line arguments as the original gccxml executable.


This document is intended as supplement to the documentation on the GCC-XML homepage. More extensive instructions may be found there.

Build / Install

The standard way to build the GCC-XML front-end is to use CMake (see links at bottom to get it). CMake will generate an appropriate build system for your platform. There are separate instructions for UNIX and Windows users.

UNIX & Cygwin

These instructions assume that the front-end will be built out-of-source (recommended), but an in-source build should also work. The example command lines assume the current working directory is just above the top-level source directory (called gccxml_plugin-<version>):

$ mkdir gccxml-build
$ cd gccxml-build
$ cmake ../gccxml -DCMAKE_INSTALL_PREFIX:PATH=/installation/path
$ make
$ make install

(The "-D..." option can be left off if you want to use /usr/local as the installation prefix.)

This will install executables called gccxml in PREFIX/bin. The plugin itself will be installed into PREFIX/lib.


Run the CMake GUI to generate the build system for your compiler. Load the resulting project file and build it. You should be able to run the executable directly from the build directory. It will be located in gccxml-build/, gccxml-build/Debug, or gccxml-build/Release depending on the build system chosen.


Once gccxml_plugin has been built, it can be run from the command line like this:

$ gcc -fplugin=gccxml_plugin.so -fplugin-gccxml_plugin-arg-xml=output.xml input.cxx

A front-end script, written in Python, has been written to provide the same command line options as the original gccxml driver. gccxml_plugin can be run like this:

$ gccxml_plugin input.cxx -fxml=output.xml

Use gccxml_plugin --help for a full list of options and configuration help.

N.B. Environment variables supported by the original GCCXML have not been implemented in the new front end script (yet?).


Once the plugin has been built, it can be tested by running ctest, in the build directory. This will search for GCC's stdc++ library headers on your system, and attempt to convert each of the standard library headers into XML.

XML Schema

An official XML schema representing GCC's Abstract Syntax Tree does not exist. However, it is possible to convert existing XML documents into an XML Schema, using machine learning algorithms. To test for differences between versions of the C++ standard library headers, it would be useful to have reference XML schemas with which to compare against.

So, providing an initial XML schema, generated by, for example XML Schema Learner, would allow testing for differences between versions of GCC.