[GCC-XML] GCC XML fails to compile standard library headers like <new>

Brad King brad.king at kitware.com
Fri Aug 7 08:19:18 EDT 2009


Hi Satarupa,

BTW, please Cc the gccxml mailing list in replies so that everyone
can benefit from the discussion.  Thanks.

satarupa pal wrote:
> Any symbian s60 project builds fine with armv5 or RVCT compiler.
> Problem comes when I try to build with GCC or GCC XML.
> 
> I am working in a tool, which does the backword binary compatibility
> check for s60 headers. The tool uses the GCC XML compiler
> (gccxml_cc1plus.exe) to parse the headers and generate a xml file with
> all dependent headers. And with these xml files of two s60 headers, we
> check the binary compatibility.

Nice.  That sounds like a really cool project.

> So, we are not authorized to modify the s60 headers to work correctly
> with GCC XML.

GCC-XML does not require modification of header files in-place.
Instead it uses its own copy of the headers with appropriate fixes.

GCC-XML was designed to parse C++ interfaces to help interpreted-language
wrapper generator tools.  In order to guarantee that these tools see
the interface of a project the same way the compiler that builds the
project does, GCC-XML needs to parse the system header files for that
compiler.  Essentially we simulate the target compiler's preprocessor,
and just define a few extra symbols (like __GCCXML__) to distinguish
GCC-XML from the actual compiler.

A challenge in this approach is that GCC-XML's internal GCC-based
parser needs to handle the system header files from other compilers
(new.h in your case).  Many compilers use vendor-specific extensions
in their headers and/or declarations that depend on implementation-
provided builtin types or functions.  Therefore we need to patch the
system headers of every target compiler so GCC can parse them...but
we don't overwrite the original headers.

There are two approaches we take to constructing the patched headers,
and choosing between them depends on the license of the headers in
question.  For freely-distributable headers we just manually copy
and fix them and then distribute them with GCC-XML.  For proprietary
headers we distribute a patch with GCC-XML and then copy the user's
already-installed version of the header and apply the patch.

Look at the GCC_XML/Support directory for current examples of patched
header files.  It comes with headers for many common compilers.  The
GCC_XML/VcInstall directory comes with tools and patch files to apply
on systems that have MS Visual Studio installed.

What you need to do is copy the problematic headers to your own
support directory and fix them.  Look at the configuration options
documented here:

  http://www.gccxml.org/HTML/Running.html

To learn how it works, you can run GCC-XML and tell it to simulate
one of the currently supported compilers.  Add the --print option
to see what it does internally.

-Brad



More information about the gccxml mailing list