I have a method
**int** create_object(Object* parent, char* name, int type, int start_block) {
...
return ptr_to_object;
}
Inside the function ptr_to_object seems to be a 32-bits but then as soon as it gets out of it, it looks like its 64-bits.
Note: I cannot use c99, I know that intptr_t is part of c99.
What are your suggestions? Thanks!
If you’re dealing with pointers, either use a pointer return type, or “hide” it in an int-type defined by the standard to be large enough to support holding a pointer. Such a type can exist but is not guaranteed to exist (tmk):
The keyword there is optional. Chance are likely it is defined on your platform of choice, but for legacy portability you’re probably better off either returning a
void *or declaring a specialized “handle” to a typed or void pointer and returning that.As always, I’m entirely interested in anyone that is working with a C99-compliant platform that chose not to expose some of the features presented as optional in the standard (like this one). If there is anyone out that with a
<stdint.h>withoutintptr_tand/oruintptr_tI’m very curious. Please leave a comment if you work with such a toolchain.