Jump to content
  • Advertisement
Sign in to follow this  
DrewGreen

MMGR compilation problems

This topic is 4760 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 trying to use MMGR in my code. I've read the -DOC- stuff but can't find anything relating to this issue. Upon compiling with VC++ 6.0 professional edition I get the following errors: C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\malloc.h(105) : warning C4002: too many actual parameters for macro 'calloc' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\malloc.h(105) : error C2059: syntax error : 'string' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\malloc.h(106) : error C2062: type 'void' unexpected C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\malloc.h(107) : error C2059: syntax error : 'string' C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\malloc.h(108) : error C2059: syntax error : 'string' but only when I #include mmgr.h the offending lines in malloc.h are:
/* Function prototypes */

_CRTIMP void *  __cdecl calloc(size_t, size_t);
_CRTIMP void    __cdecl free(void *);
_CRTIMP void *  __cdecl malloc(size_t);
_CRTIMP void *  __cdecl realloc(void *, size_t);



but I doubt that malloc.h is the problem. I don't know what's going on at all here. Can someone help please? edit: also my program isn't using mfc. It's a modified version of the NeHe OpenGL basecode. If compiler settings will help they are standard release mode settings with the following libraries linked: opengl32.lib glu32.lib glaux.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib compiling in debug mode also causes the same problem

Share this post


Link to post
Share on other sites
Advertisement
I've just tried it like you suggested (using the basecode & lesson5.cpp) & it all worked correctly. So I know it's something to do with my code. The thing is though I haven't used malloc or calloc anywhere myself, so I don't get what's causing this problem, especially as it's compiling correctly without mmgr.

Share this post


Link to post
Share on other sites
DrewGreen,

You need to doublecheck that your includes are setup right. Remember that you want to include all files found in the compiler directories first, then the mmgr.h, then your includes for your project. I'm 99.9% sure that that is the reason your getting errors.

Hope that helps!

-brad

Share this post


Link to post
Share on other sites
Yep, I've done that. As I say, I did bother to RTFM :)


#include <windows.h>
#include <stdio.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include "mmgr.h"
#include "GLEXT.h"
#include "FrameTimer.h"
#include "NeHeGL.h"
#include "MilkshapeModel.h"
#include "base.h"
#include "Game.h"




I tried a couple other position combinations, such as swapping mmgr.h with GLEXT.h but it made no difference

Share this post


Link to post
Share on other sites
The problem I'm always facing is that those headers you're including after mmgr.h can not include any standard headers. This plays havoc with templates using stl containers; there's no way to correctly include them using mmgr.

Share this post


Link to post
Share on other sites
^ Actually yeah I've checked the #includes in the other files & it looks like I can't avoid this then :/

Thanks everyone for your help.

Can someone recommend an alternative to MMGR? It would be nice to be able to detect leaks etc.


Share this post


Link to post
Share on other sites
What you need to do is always follow this pattern in your files:


#include "nommgr.h"
//system includes
#include "mmgr.h"
//your includes




Edit: sorry pressed post to quickly...

nommgr.h will undefine all macros that the memory manager uses for system includes and then mmgr.h will enable them again for your files. I have my whole project set up like this and it seems to work fine. Just make sure you dont edit the mmgr files often - having every file in your program recompiled is murder.

I had to run MMGR on an amd64 and a nice standard compilant compiler (gcc) and got lots of compiler warnings etc (mmgr used fairly C:ish syntax), it also didnt work at all on amd64 since it for some reason assumed longs to always be 4 bytes. There was also some versions of new/delete from the newer c++ standard that was missing.
If anyone is interrested I can put up the modified code somewhere.

Share this post


Link to post
Share on other sites
Quote:
Original post by DrewGreen
Can someone recommend an alternative to MMGR? It would be nice to be able to detect leaks etc.


if you have access to a gnu box, try Valgrind

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!