[GCC-XML]Wrong output in version 0.4.1?

Nicodemus nicodemus at globalite.com.br
Sat Feb 22 12:35:46 EST 2003


Brad King wrote:

>Specialization is not allowed in a class scope (see 14.7.3).  The above
>example is invalid C++ code, so intel is wrong to compile it, and gccxml
>is correct in giving the error.  To correctly specialize the member, you
>need to place the following lines after the definition of struct C:
>
>    template <>
>    void C::foo<int>()
>    {
>        int x;
>    }
>  
>

Hmm, didn't know that! Thanks for enlightening me. 8)

And you are right, this code, using member templates:

struct C
{
    template <class D>
    void foo()
    {
        D d;
    }
};

void x()
{
    C c;
    c.foo<double>();
    c.foo<int>();
}  

Doesn't compile in msvc6, but compiles without trouble with intel and 
gccxml.

>Ignoring this problem, GCC-XML uses GCC 3.0.4 under the hood to do
>parsing.  It will support all of GCC's features even if it thinks it is
>simulating msvc 6.  When we say GCC-XML "simulates" a compiler, it does
>not duplicate the compiler's bugs and limitations.  The idea is that the
>compiler's library of header files is used so that the XML dump sees
>approximately the same translation unit as the compiler sees.  This is
>useful for tools that generate code based on type information in the XML
>dump.  The generated code must have consistent type information with the
>compiler that will build it.
>  
>

Nice to know that. Indeed, that's why I want to make gccxml use STLport 
instead of the native library, because there's differences in the 
implementations that are significant to my work.

> That is an oversight in the implementation that no one has noticed until
> now.  The compiler simulation flags are added first, and then the user
> flags.  It should be the other way around.  I've fixed this in the CVS
> head of the GCC-XML front-end.  If you check it out from CVS (insturctions
> on web page), you can build it and still use the gccxml_cc1plus exectuable
> from 0.4.1.

I've done that, but it doesn't seem to work... 8(. I compiled gccxml 
without any problems (thanks to CMake), and replaced the gccxml.exe from 
the distribution. So, my first try:

]set GCCXML_USER_FLAGS=-ID:\Programming\Libraries\STLport-4.5.3\stlport

]set GCCXML_USER_FLAGS
 > -ID:\Programming\Libraries\STLport-4.5.3\stlport

]gccxml --print
 > GCC-XML version 0.5.development
 > Configuration settings:
 >   GCCXML_CONFIG="C:/Progra~1/GCC_XML/config"
 >   GCCXML_COMPILER="cl"
 >   GCCXML_CXXFLAGS=""
 >   GCCXML_EXECUTABLE="C:/Progra~1/GCC_XML/gccxml_cc1plus.exe"
 >   GCCXML_FLAGS="-quiet -o NUL -nostdinc -I- -w -fsyntax-only 
-D__stdcall= -D__cd
 > ecl= -D_stdcall= -D_cdecl= -D__declspec(x)= -D_inline=inline 
-D__uuidof(x)=IID()
 >  -D__int64='long long' -D__cplusplus -D_MSC_VER=1200 
-D_MSC_EXTENSIONS -D_WIN32
 > -D_M_IX86 -D_WCHAR_T_DEFINED -DPASCAL= -DRPC_ENTRY= 
-DSHSTDAPI=HRESULT -DSHSTDAP
 > I_(x)=x -I"C:/Progra~1/GCC_XML/Vc6/Include" -I"C:/Program 
Files/Microsoft Visual
 >  Studio/VC98/Include" "
 >   GCCXML_USER_FLAGS="-ID:\Programming\Libraries\STLport-4.5.3\stlport"
 >   GCCXML_ROOT="C:/Progra~1/GCC_XML"

GCCXML seems to be configured correctly

]type test.h
 > #include <algorithm>
 >
 > using namespace std;
 >
 > void x()
 > {
 >     std::max(3, 4);
 > } 


]cl /Tp test.h /c
 > Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 
80x86
 > Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
 >
 > test.h
 > test.h(7) : error C2039: 'max' : is not a member of 'std'
 > test.h(7) : error C2065: 'max' : undeclared identifier

Ok, using the native libraries: min e max are not defined.

]cl %GCCXML_USER_FLAGS /Tp test.h /c
 > Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 
80x86
 > Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
 >
 > test.h

Using stlport it compiles without problem.

Now lets parse it using gccxml...

]gccxml -fxml=out.xml test.h
 > test.h: In function `void x()':
 > test.h:7: `max' undeclared in namespace `std'

It doesn't seem to be putting the USER_FLAGS first, because it keeps 
using the native libraries.

I tried to fiddle a little in the source code, and found this part in 
gxFront.cxx (line 113):
 
    // Parse the flags.
    gxFlagsParser parser;
    parser.Parse(cGCCXML_FLAGS.c_str());
    parser.Parse(cGCCXML_USER_FLAGS.c_str());

I changed it to:

    // Parse the flags.
    gxFlagsParser parser;
    parser.Parse(cGCCXML_USER_FLAGS.c_str());
    parser.Parse(cGCCXML_FLAGS.c_str());


But the result is the same:

]gccxml -fxml=out.xml test.h
 > test.h: In function `void x()':
 > test.h:7: `max' undeclared in namespace `std'

I think I'm using it wrong... can someone point me in the right 
direction? Thanks for your help so far Brad.

Farewell,
Nicodemus.






































More information about the gccxml mailing list