J
James Brown [MVP]
Hi,
I am having trouble understanding how the 'const' modifier affects the
'left-right' rule when deciphering c-declarations:
const int *x; // x is a pointer to a 'const int'
int const *x; // ??
these are the same, right? in this case the basetype is 'const int' ?
int * const x = 0; // x is a const-pointer to int
int (* const )x = 0; // same as above
do the brackets have any significance here? I think not in this case..
int (const * x)[2]; // x is a const-pointer to array[2] of int
int const *x[2]; // x is an array[2] of const-pointer to int
have I understood these correctly?
really I am having trouble understanding what the significance is of the
const-keyword being on the left or right of a '*'...I am writing a small
c-declaration parser as this is helping me to understand the syntax of
c-style declarations..
thanks,
James
I am having trouble understanding how the 'const' modifier affects the
'left-right' rule when deciphering c-declarations:
const int *x; // x is a pointer to a 'const int'
int const *x; // ??
these are the same, right? in this case the basetype is 'const int' ?
int * const x = 0; // x is a const-pointer to int
int (* const )x = 0; // same as above
do the brackets have any significance here? I think not in this case..
int (const * x)[2]; // x is a const-pointer to array[2] of int
int const *x[2]; // x is an array[2] of const-pointer to int
have I understood these correctly?
really I am having trouble understanding what the significance is of the
const-keyword being on the left or right of a '*'...I am writing a small
c-declaration parser as this is helping me to understand the syntax of
c-style declarations..
thanks,
James