DEBUGGING without DEBUG

Discuss programming topics for the various GPL'd game engine sources.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: DEBUGGING without DEBUG

Post by r00k »

So i need to float my boat to (codeblocks with mingw64) land and drink a bottle of debug for breakfast ;)
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: DEBUGGING without DEBUG

Post by revelator »

what can i say :P with the work i put in it im pretty happy with my compiler hehe.
Productivity is a state of mind.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: DEBUGGING without DEBUG

Post by Knightmare »

It was the byte order functions, or more specifically the function pointers that are bound on startup after detecting byte order. I did a build that bypassed them, hardcoding function calls, and it worked perfectly. After referring to the RtCW source, I found that the pointers needed to be static to work right with newer Visual Studio versions.

Here's the fixed code in q_shared.c:

Code: Select all

// can't just use function pointers, or dll linkage can
// mess up when qcommon is included in multiple places
// Knightmare- made these static
static short	(*_BigShort) (short l);
static short	(*_LittleShort) (short l);
static int		(*_BigLong) (int l);
static int		(*_LittleLong) (int l);
static qint64	(*_BigLong64) (qint64 l);
static qint64	(*_LittleLong64) (qint64 l);
static float	(*_BigFloat) (float l);
static float	(*_LittleFloat) (float l);

short	BigShort(short l){return _BigShort(l);}
short	LittleShort(short l) {return _LittleShort(l);}
int		BigLong (int l) {return _BigLong(l);}
int		LittleLong (int l) {return _LittleLong(l);}
qint64	BigLong64 (qint64 l) {return _BigLong64(l);}
qint64	LittleLong64 (qint64 l) {return _LittleLong64(l);}
float	BigFloat (float l) {return _BigFloat(l);}
float	LittleFloat (float l) {return _LittleFloat(l);}
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: DEBUGGING without DEBUG

Post by revelator »

nice catch :) this should also apply to quake 1
Productivity is a state of mind.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: DEBUGGING without DEBUG

Post by r00k »

Thanks Knightmare!
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: DEBUGGING without DEBUG

Post by revelator »

noticed for gcc you need to call the static function pointers instead of the prototype or it will fail to build with invalid lvalue.

so in quake1's common.c call them like this _BigShort = ShortSwap etc.
Productivity is a state of mind.
Post Reply