[GCC-XML]typdef vs. tagged enums
John Waggenspack
jwag at celion.com
Wed Mar 31 18:26:56 EST 2004
These enums:
enum tagged {
tagged0
};
typedef enum {
tdeffed0
} tdeffed;
Generate the following xml:
<?xml version="1.0"?>
<GCC_XML>
<Namespace id="_1" name="::" members="_3 _4 " mangled="_Z2::"/>
<Namespace id="_2" name="std" context="_1" members="" mangled="_Z3std"/>
<Enumeration id="_3" name="tdeffed" context="_1" location="f0:8" file="f0" line="8">
<EnumValue name="tdeffed0" init="0"/>
</Enumeration>
<Enumeration id="_4" name="tagged" context="_1" location="f0:2" file="f0" line="2">
<EnumValue name="tagged0" init="0"/>
</Enumeration>
<File id="f0" name="test.h"/>
</GCC_XML>
Note there is no difference in the XML output for the two different styles of enum specification.
However, gcc 2.95 expect functions that use these enums to have different signatures.
This compiles without errors:
#include "test.h"
extern void foo();
enum tagged returnTagged()
{
return(tagged0);
}
tdeffed returnTdeffed()
{
return(tdeffed0);
}
void useTagged(enum tagged e)
{
if (e == tagged0)
foo();
}
void useTDeffed(tdeffed e)
{
if (e == tdeffed0)
foo();
}
This has errors:
#include "test.h"
extern void foo();
tagged returnTagged()
{
return(tagged0);
}
enum tdeffed returnTdeffed()
{
return(tdeffed0);
}
void useTagged(tagged e)
{
if (e == tagged0)
foo();
}
void useTDeffed(enum tdeffed e)
{
if (e == tdeffed0)
foo();
}
gcc -c test_ERRORS.c
test_ERRORS.c:5: syntax error before `returnTagged'
test_ERRORS.c:11: return-type is an incomplete type
test_ERRORS.c: In function `returnTdeffed':
test_ERRORS.c:12: warning: `return' with a value, in function returning void
test_ERRORS.c: At top level:
test_ERRORS.c:15: syntax error before `e'
test_ERRORS.c: In function `useTagged':
test_ERRORS.c:17: `e' undeclared (first use in this function)
test_ERRORS.c:17: (Each undeclared identifier is reported only once
test_ERRORS.c:17: for each function it appears in.)
test_ERRORS.c: At top level:
test_ERRORS.c:22: parameter `e' has incomplete type
Is there anyway to have the generated XML indicate if an enum is
typedefed?
Thanks,
jwag
More information about the gccxml
mailing list