Jump to content
  • Advertisement
Sign in to follow this  
thedustbustr

using stl with memory managed code

This topic is 4165 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using an engine which has its own memory manager. STL won't compile under the engine's memory manager, so I can't really have STL includes in header files, short of having a global include file which every single source and header file includes first. I know that using forward declarations the compiler doesn't have size information. So, is there a workaround to accomplish something like this?
template <> class std::vector;

class A {
std::vector<int> data;
}

Share this post


Link to post
Share on other sites
Advertisement
Why not include the memory management headers after you include the SC++L headers? That should eliminate the compiler issues, unless they're particularly complex ones. What exactly causes the failure to compile?

Share this post


Link to post
Share on other sites
there are very complex header chains that are not my code to refactor. I don't know if they even can be refactored.

if I include <vector> in my header, then another header file includes my header (but not at the very top), the latter header will not compile. Its very easy to get chains that are not terribly complicated that have no solution order that compiles. I wouldn't want to waste my time and sacrifice my organization to find such a sol'n anyway.

It's either a global include-me-first include file with every single used STL header (and any other external libraries that I don't want memory managed...), or forward declarations of some sort. I don't like the idea of global headers.

Share this post


Link to post
Share on other sites
Still doesn't answer my question, what are the compilation errors? There are still potential trivial solutions to the problem.

Lots of memory management tools use macros to replace new and delete, for example; that can cause errors. This can be avoided by including simple headers that undefine and redefine the macros, using those to bracket the SC++L headers.

Share this post


Link to post
Share on other sites
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1118) : error C2653: 'MemoryMgr' : is not a class or namespace name
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1118) : error C2833: 'operator SetCurrentLocation' is not a recognized operator or type
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1118) : error C2059: syntax error : 'newline'
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1118) : error C2059: syntax error : 'new'
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1120) : error C2653: 'MemoryMgr' : is not a class or namespace name
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1120) : error C2833: 'operator SetCurrentLocation' is not a recognized operator or type
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1120) : error C2059: syntax error : 'newline'
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1120) : error C2059: syntax error : 'new'
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1127) : error C2653: 'MemoryMgr' : is not a class or namespace name
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1127) : error C2833: 'operator SetCurrentLocation' is not a recognized operator or type
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1127) : error C2059: syntax error : 'newline'
1>c:\program files\microsoft visual studio 8\vc\include\crtdbg.h(1127) : error C2059: syntax error : 'new'


The engine I am using has no such "unclusion" headers, that I am aware of.

Share this post


Link to post
Share on other sites
Perhaps you can make some. Offhand (and I don't have a copy to look at right now), crtdbg.h doesn't have a MemoryMgr class, so it's not a class conflict in any way...

It sounds like there is some macro you've got that is being replaced to reference MemoryMgr, et cetera, and that macro is in scope before you include external headers (it really, really should not be, its usually a huge pain to accurately track the memory used by external code and often not worth it).

See if your memory manager employs macros in any way. If it does, you can create disabling headers yourself. Otherwise I'd probably need more information about how the manager works and looks like to provide solid alternative solutions.

Share this post


Link to post
Share on other sites
Yeah, that's basically my understanding. I'm really hoping to not have to modify the engine / add headers / do whatever at a low level. I've brought this issue to their community, hopefully they have a solution.

Share this post


Link to post
Share on other sites
aaand unfortunately its not using macros very heavily.

My peer got it to compile, and now we have vector internally memory managed by our engine. It works, but is sketchy as hell and I for one am not comfortable with this game engine managing external code.

Can anyone comment on using STL or other std:: stuff with a custom new operator?

Also, if a mod can move this to general programming, because this is no longer a beginner's discussion...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!