Sign in to follow this  
DrewGreen

MMGR compilation problems

Recommended Posts

DrewGreen    370
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
DrewGreen    370
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
Galapaegos    277
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
DrewGreen    370
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
rick_appleton    864
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
DrewGreen    370
^ 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
rollo    366
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this