int * const const * b
What does it mean? cdecl says declare b as pointer to const const pointer to int.
Can someone explain it?
const const is redundant, it will reduce to const.
So let's rewrite that:
int * const *b;
So b is a pointer to a const pointer to an int. With an example:
int main(int argc, char **argv) {
int i = 5;
int *ip = &i;
int * const const * b = &ip;
(**b)++; /* legal */
(*b)++; /* illegal */
(b)++; /* legal */
return 0;
}
Also see that question, this is valid C99, but not valid C++ nor valid C89.
It's just a pointer to a const pointer to an integer. Const applies to what is on its left unless there is nothing on its left: then it applies on the right.
Here you just have redundant redundancy, which is repeated such that you're really sure that it is const and will not mutate.
Here you just have redundant redundancy, which is repeated such that you're really sure that it is const and will not mutate.
Even cdecl.org tells that b is pointer to const const pointer to int.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With