New" operator
by Flashback · in Torque Game Engine · 09/12/2005 (1:52 pm) · 3 replies
I was trying to integrate some of my code from old engine into Torque, but received next errors:
I didn't try to redefine "new" operator in my code, of course. So I went and checked TGE's winMemory.cc. What I saw there is "new", redeclared like this:
I'm not sure why did you do this... for some sort of compatibility, I guess, as FN_CDECL is just redefined __cdecl in typesWin32.h. Anyway, I couldn't make it working, and I had to comment it ("new" redeclaration) out. See winMemory.cc, lines 41-43. Everything started working.
I wonder what was that redeclaration for? Will I meet any problems in future because of this?
Linking... control.obj : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj character.obj : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj ../example/AoD.exe : fatal error LNK1169: one or more multiply defined symbols found
I didn't try to redefine "new" operator in my code, of course. So I went and checked TGE's winMemory.cc. What I saw there is "new", redeclared like this:
void* FN_CDECL operator new(dsize_t, void* ptr)
{
return (ptr);
}I'm not sure why did you do this... for some sort of compatibility, I guess, as FN_CDECL is just redefined __cdecl in typesWin32.h. Anyway, I couldn't make it working, and I had to comment it ("new" redeclaration) out. See winMemory.cc, lines 41-43. Everything started working.
I wonder what was that redeclaration for? Will I meet any problems in future because of this?
About the author
Programmer at Iron Tower Studio
#2
09/12/2005 (5:48 pm)
You can disable Torque's memory manager, too - there's a macro for it in platform.h, I believe. Of course, then you lose the various debugging aids it'll give you.
#3
Torque uses it's own memory manager. As such, code (like the STL, or your old engine apparently) don't play well with the torque code base.
Ah, STL stuff... OK, I'm warned.
I'm not sure what's involved in changing the source so it's compatible with torque, but the answers are probably partially hidden within the STL-related threads you'll find around here. That "search" link in the upper right corner of the page is great.
I have already noticed it :) Thanks, Mark.
@Ben Garney
You can disable Torque's memory manager, too - there's a macro for it in platform.h, I believe. Of course, then you lose the various debugging aids it'll give you.
This is a way out too, after all. Thank you for the tip.
09/13/2005 (12:02 am)
@Mark StorerTorque uses it's own memory manager. As such, code (like the STL, or your old engine apparently) don't play well with the torque code base.
Ah, STL stuff... OK, I'm warned.
I'm not sure what's involved in changing the source so it's compatible with torque, but the answers are probably partially hidden within the STL-related threads you'll find around here. That "search" link in the upper right corner of the page is great.
I have already noticed it :) Thanks, Mark.
@Ben Garney
You can disable Torque's memory manager, too - there's a macro for it in platform.h, I believe. Of course, then you lose the various debugging aids it'll give you.
This is a way out too, after all. Thank you for the tip.
Torque Owner Mark Storer
I'm not sure what's involved in changing the source so it's compatible with torque, but the answers are probably partially hidden within the STL-related threads you'll find around here. That "search" link in the upper right corner of the page is great.
--Mark