Compiler error

Member
Posts: 45
Joined: 2006.11
Post: #1
I'm having trouble fixing this error from the following code (part of OpenGL Shading Language Compiler):
Code:
typedef pool_allocator<char> TStringAllocator;
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
inline TString* NewPoolTString(char* s)
{
    void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
    return new(memory) TString(s);
}
This also has to do with Intermediate.h, which is too big to post. You can download the compiler at http://www.3dlabs.com/support/developer/.../index.htm

I get the following errors:
Code:
In file included from include/intermediate.h:36,
                 from MachineIndependent/Initialize.cpp:28:
/usr/include/gcc/darwin/3.1/g++-v3/bits/basic_string.h: In instantiation of `std::basic_string<char, std::char_traits<char>, TStringAllocator>::_Rep':
/usr/include/gcc/darwin/3.1/g++-v3/bits/basic_string.tcc:67:   instantiated from `std::basic_string<char, std::char_traits<char>, TStringAllocator>'
include/common.h:64:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/basic_string.h:126: no class template named `rebind' in `class TStringAllocator'
include/common.h:83: warning: ISO C++ forbids declaration of `Min' with no type
include/common.h:84: warning: ISO C++ forbids declaration of `Max' with no type
In file included from MachineIndependent/Initialize.cpp:28:
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_alloc.h: In instantiation of `std::_Alloc_traits<TIntermNode*, pool_allocator<TIntermNode*> >':
include/intermediate.h:432:   instantiated from `std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `std::vector<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `TVector<TIntermNode*>'
include/intermediate.h:432:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_alloc.h:844: no class template named `rebind' in `class pool_allocator<TIntermNode*>'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h: In instantiation of `std::_Vector_alloc_base<TIntermNode*, pool_allocator<TIntermNode*>, false>':
include/intermediate.h:432:   instantiated from `std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `std::vector<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `TVector<TIntermNode*>'
include/intermediate.h:432:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:90: no type named `allocator_type' in `struct std::_Alloc_traits<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:82: no type named `allocator_type' in `struct std::_Alloc_traits<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:83: no type named `allocator_type' in `struct std::_Alloc_traits<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:86: no type named `allocator_type' in `struct std::_Alloc_traits<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h: In instantiation of `std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >':
include/intermediate.h:432:   instantiated from `std::vector<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `TVector<TIntermNode*>'
include/intermediate.h:432:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:134: no type named `allocator_type' in `class std::_Vector_alloc_base<TIntermNode*, pool_allocator<TIntermNode*>, false>'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h: In instantiation of `std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >':
include/intermediate.h:432:   instantiated from `std::vector<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `TVector<TIntermNode*>'
include/intermediate.h:432:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:136: no type named `allocator_type' in `class std::_Vector_alloc_base<TIntermNode*, pool_allocator<TIntermNode*>, false>'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h: In instantiation of `std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >':
include/intermediate.h:432:   instantiated from `std::vector<TIntermNode*, pool_allocator<TIntermNode*> >'
include/intermediate.h:432:   instantiated from `TVector<TIntermNode*>'
include/intermediate.h:432:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:137: no type named `allocator_type' in `class std::_Vector_alloc_base<TIntermNode*, pool_allocator<TIntermNode*>, false>'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h: In instantiation of `std::vector<TIntermNode*, pool_allocator<TIntermNode*> >':
include/intermediate.h:432:   instantiated from `TVector<TIntermNode*>'
include/intermediate.h:432:   instantiated from here
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:186: no type named `allocator_type' in `struct std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:187: no type named `allocator_type' in `struct std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:333: no type named `allocator_type' in `struct std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:337: no type named `allocator_type' in `struct std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:352: no type named `allocator_type' in `struct std::_Vector_base<TIntermNode*, pool_allocator<TIntermNode*> >'
/usr/include/gcc/darwin/3.1/g++-v3/bits/stl_vector.h:352: confused by earlier errors, bailing out

I can't seem to determine what the problem is. I see rebind in the STL header files, yet it seems to think it is not there....
Quote this message in a reply
Sta7ic
Unregistered
 
Post: #2
Is it just me, or is it trying to repeat class declarations (a double include)?
It might also be a wierd invis ASCII character that's throwing something off, as all the errors are on line 432, but that's a long shot.
Quote this message in a reply
Member
Posts: 45
Joined: 2006.11
Post: #3
Good idea... but nope on both fronts. Some of the header files were not wrapped with #ifndef HEADER_NAME_H_INCLUDED and some of the #includes had "../Include/..." rather than "../include/..." but after fixing all of these, I had the same errors. After a bit of searching, I think it has to do with either the typename keyword or with Apple's STL implementation relative to MSVC++'s STL implementation, or quite possibly it could be both. The code has a few other non-conformant sections, such as the use of itoa, which are not standards conformant. I suspect that the typename keyword usage is to blame. If this is true, I'll have to correct significant amounts of code, because that keyword is used extensively.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
You might like to try compiling with GCC 2.95 rather than 3.1, as 3.1 is rather stricter about typename than 2.95.

My personal guess, though, is simply differences in the STL between the two. The "S" in the acronym is rather misleading...
Quote this message in a reply
henryj
Unregistered
 
Post: #5
The first error looks like it's saying that pool_allocator doesn't have the right interface to be used with basic_string...

Quote:/usr/include/gcc/darwin/3.1/g++-v3/bits/basic_string.h:126: no class template named `rebind' in `class TStringAllocator'


The rest of the errors are probably related or red herrings
Quote this message in a reply
Member
Posts: 45
Joined: 2006.11
Post: #6
Heh, they should call it MTL "Microsoft Template Library" in Visual C++. Wink
Gcc2.x compiles with the same errors.
I'll look into the allocator interface.... I don't have a decent and up to date STL reference, so I'll have to search the web. Thanks for all the comments. I'm a little inexperienced with porting code, so I'm not always sure of what to look for.
Quote this message in a reply
henryj
Unregistered
 
Post: #7
You should have said. You're in for a world of trouble trying to port from MSVS.

Searching through the headers on your MAC will be just as good as searching the net. Find out what rebind does and add it to your pool_allocator.
Try looking in somewhere like bits/stl_alloc.h or similar.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Open Source Cg compiler adventures JeroMiya 4 4,392 Sep 16, 2002 06:58 PM
Last Post: JeroMiya
  BSP tree compiler ClarustheDogCow 3 3,711 Jul 4, 2002 09:30 AM
Last Post: ClarustheDogCow