I should probably know this, but...
I'm writing a series of functions that return pointers to objects. In the case that an error occurs I am returning a hex value instead of a pointer.
My return codes start at 0x00000 and I'm planning to have around 20-50.
I have investigated many pointers with my debugger and noticed that pointer values are generally much higher than this. Is this purely by coincidence or is it safe to assume a certain range that will NOT interfere with memory in my application?
Forgot to mention that my target system is current versions of windows (XP to 7).
Yes, I believe the lower addresses are used by the system. However, I think you should consider an alternative method of returning error codes.
Why not return NULL when an error occurs. That's the convention for pointers atleast.
And any address return'd will be logical so there's no conflict between user / kernel space.
itcbitc, He also wants to return information about the error, but I'm guessing he doesn't want to make extra room for the error code.
This might be slightly more convenient for you right now, but I (along with most others) would consider relying on the value of pointers (other than 0/NULL) to be poor practice.
Yes, I'm trying to create code that provides error information so I can deal with it in calling functions.
Originally Posted by NeonBlack
I suppose this method isn't very expandable. I suppose the best way to deal with this would be to create a separate error handling class?
Well you could return hex values looking something like this. That if you want to do it the way wanted it to be
#define RET_CODE_1 0x200
#define RET_CODE_2 0x201
#define RET_CODE_3 0x202
#define RET_CODE_4 0x203
#define RET_CODE_5 0x204