How to use 64/32 bit pointers

I have a problem. I want to set pointers to a default value for both 32 bit and 64 bit compiles. The 32-bit version works as:

enum constants { UNDEFINED = 0xDeadBeef }

if ((unsigned long)ptr == UNDEFINED)

but I can't seem to extend this to 64-bits. I've tried
#if __SIZEOF_POINTER__ == 4
enum constants { UNDEFDATA = 0xDeadBeef };
}; // enum constants
#elif __SIZEOF_POINTER__ == 8
enum constants { UNDEFDATA = 0xDeadBeefDeadBeef };
#endif

with:
if (ptr == UNDEFINED)

but get a message saying the '==' is undefined (I understand this)

Is there any way to setup so that I can change the size of my constants so that the comparisons will always work correctly? I've tried a 'typedef' but the compiler complains at
'typedef unsigned long long ADDR' // won't accept, and
static const SlipCellBase * const TEMPORARY = (SlipCellBase&)0xFFFFFFFFFFFFFFFF; // illegal conversion

enum doesn't work (because it's an int?) and I'm out of ideas.


Not really a direct answer to your question... but why not just use null/nullptr/0 to indicate an invalid pointer? That's exactly what it's for.
Topic archived. No new replies allowed.