[GCC-XML] Adding meta-information.

Brad King brad.king at kitware.com
Sun Mar 30 15:42:14 EDT 2008


Chris Waldron wrote:
> I noticed in the documentation that GCC-XML support the ability to add 
> meta-information in the C++ source that can be read by GCC-XML as follows…
> 
>  
> 
> |*__attribute((gccxml(<string>, <string>, ...)))*|: Here <string> is a 
> quoted string. There must be at least one argument to the 'gccxml' 
> attribute, but there is no upper limit to the total number of arguments. 
> Each argument is verified to be a string - if a non-string argument is 
> found, the attribute is ignored.
> 
>  
> 
> What I’d like to know is whether this will work for Microsoft C++ as 
> well or is this feature specific for GCC.

The __attribute syntax is specific to gcc, but that's okay.  The syntax will 
work in gccxml no matter what compiler you are simulating because gccxml 
always parses using a patched gcc parser.  You just have to use macros to 
avoid using the attribute syntax when a compiler other than gccxml is in use:

#ifdef __GCCXML__
# define MY_GCCXML_ATTRIBUTES(x) __attribute(x)
#else
# define MY_GCCXML_ATTRIBUTES(x)
#endif

Then in the code use the macro to specify attributes.  All compilers will 
ignore them but gccxml will see them.

-Brad



More information about the gccxml mailing list