please consider the following code:
typedef struct Person* PersonRef;
struct Person {
int age;
};
const PersonRef person = NULL;
void changePerson(PersonRef newPerson) {
person = newPerson;
}
For some reason, the compiler is complaining about read-only value not assignable. But the const keyword should not make the pointer const. Any ideas?
Note that
is not the same as:
intptris pointer to int.const intptris constant pointer toint, not pointer to constantint.There are some ugly ways, such as gcc’s typeof macro:
but, as you see, it’s pointless if you know the type behind
intptr.