Problems with STL
by Sylvain Boivin · in Torque Game Engine · 03/23/2005 (8:22 am) · 6 replies
Hi
I have a problem with the STL. It is useful that you know that : I use Microsoft Visual C++ .NET 2003. I have a problem withSTH_fix.h, this header was created to use the STL. When I'm doing the 'includes' of the STL, the code can be compilated.But at the moment I use data structures like vector, list, etc... , and with that structure I have an allocation of allocator who as to be done, I have a syntax error at compilation time, in the method construct.
There's the method I'm talking about:
//! Constructs an element of \c T at the given pointer.
/*! Effect: new( element ) T( arg )
*/
void construct( pointer ele, const T& arg)
{
new(ele) T(arg); // <---- A syntax error with new(ele)
}
Here's a sample of code that causing problem:e :
#include "stl_fix.h"
#include
using namespace std;
void foo()
{
vector bar;
bar.resize(10);
bar.push_back(1);
}
I know that you don't support stl_fix.h, but, maybe you can be of any help, or maybe you have faced the same problem. Thanks a lot, and have a nice day ! ;)
I have a problem with the STL. It is useful that you know that : I use Microsoft Visual C++ .NET 2003. I have a problem withSTH_fix.h, this header was created to use the STL. When I'm doing the 'includes' of the STL, the code can be compilated.But at the moment I use data structures like vector, list, etc... , and with that structure I have an allocation of allocator who as to be done, I have a syntax error at compilation time, in the method construct.
There's the method I'm talking about:
//! Constructs an element of \c T at the given pointer.
/*! Effect: new( element ) T( arg )
*/
void construct( pointer ele, const T& arg)
{
new(ele) T(arg); // <---- A syntax error with new(ele)
}
Here's a sample of code that causing problem:e :
#include "stl_fix.h"
#include
using namespace std;
void foo()
{
vector
bar.resize(10);
bar.push_back(1);
}
I know that you don't support stl_fix.h, but, maybe you can be of any help, or maybe you have faced the same problem. Thanks a lot, and have a nice day ! ;)
About the author
#3
I haven't done a seperate resource yet but Thomus Lund uses stl in the GameSWF. Simple follow the instructions here to get it working, obviously you can stop at the adding OpenSWG bit, if you don't won't the cool Flash support.
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7119
03/23/2005 (1:28 pm)
Stl_fix.h requires a patch to the memory manager. I haven't done a seperate resource yet but Thomus Lund uses stl in the GameSWF. Simple follow the instructions here to get it working, obviously you can stop at the adding OpenSWG bit, if you don't won't the cool Flash support.
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7119
#4
Yep, that's the one, and all the flamage might be why I didn't bookmark it. Thanks!
03/23/2005 (5:44 pm)
@Todd:Yep, that's the one, and all the flamage might be why I didn't bookmark it. Thanks!
#5
I didn't even read past the first few posts when I went looking for it. I then went back this morning to read through it and I have to agree thats a pretty ugly thread.
03/24/2005 (7:20 am)
@AndrewI didn't even read past the first few posts when I went looking for it. I then went back this morning to read through it and I have to agree thats a pretty ugly thread.
#6
I don't know much about STL but I know that the resource includes
an stl_fix.h file that may be of use to you, along with the modifications
to the platform memory handling code. Instead of disabling Torque's
memory manager this resource works alongside it, highly recommended.
--Midhir
04/17/2005 (10:02 pm)
Ugly thread but I can vouch that the code works for 1.3 and the 1.4 head. I don't know much about STL but I know that the resource includes
an stl_fix.h file that may be of use to you, along with the modifications
to the platform memory handling code. Instead of disabling Torque's
memory manager this resource works alongside it, highly recommended.
--Midhir
Torque Owner Andrew Haydn Grant
The problem stems from Torque's custom memory manager, which has some nice features that you probably want to keep. You can disable the memory manager completely with a compile-time flag, and that should fix the problem. (Does anyone out there know what that flag is offhand?)
Alternately, you can include the STL header files *before* including "platform.h". STL will then use the normal memory manager, and everything else will use the Torque memory manager. The easiest way to include STL before "platform.h" would be to include STL *in* "platform.h". If that hits your compile times too heavily, you'll need to include STL at the top of every .cpp file that uses STL. This isn't too bad, since the compiler will let you know which files need the includes.
FYI, the exact feature of the Torque memory manager that causes the issue is a #define that changes "new" to record __FILE__ and __LINE__. This is a great debugging feature that it would be painful to lose.