The size of the pointer depends on the arch of the machine.
So sizeof (int *) = sizeof (int) or sizeof (int *) = sizeof (long int)
I want to have a custom data type that is either int or long int depending on the size of the pointer.
I tried using macroC # if, but the condition for macros does not allow the sizeof operator.
Also, when using if-else, typedef is limited to the if area.
if((sizeof(int)==sizeof(int *)){
typedef int ptrtype;
}
else{
typedef long int ptrtype;
}
Is there a way to define ptrtype globally?
source
share