J
junky_fellow
N869, Page 47,
"Except when it is the operand of the sizeof operator or the unary &
operator, or is a string literal used to initialize an array, an
expression that has type ''array of type'' is converted to an
expression with type ''pointer to type'' that points to the
initial element of the array object and is not an lvalue."
Now, consider following piece of code,
char arr[10]; /* (line 1) */
char (*arr_ptr)[10]; /* (line 2) */
arr_ptr = &arr; /* (line 3) */
&arr should have type, pointer to array of 10 chars. But, on
compilation I get the following errors.
1) In this statement, & before array "arr" is ignored.
2) In this statement, the referenced type of the pointer
value "&arr" is "signed char", which is not compatible
with "array [3] of signed char".
Why "line 3" is giving the above warnings ? arr_ptr and &arr
both have the same types.
"Except when it is the operand of the sizeof operator or the unary &
operator, or is a string literal used to initialize an array, an
expression that has type ''array of type'' is converted to an
expression with type ''pointer to type'' that points to the
initial element of the array object and is not an lvalue."
Now, consider following piece of code,
char arr[10]; /* (line 1) */
char (*arr_ptr)[10]; /* (line 2) */
arr_ptr = &arr; /* (line 3) */
&arr should have type, pointer to array of 10 chars. But, on
compilation I get the following errors.
1) In this statement, & before array "arr" is ignored.
2) In this statement, the referenced type of the pointer
value "&arr" is "signed char", which is not compatible
with "array [3] of signed char".
Why "line 3" is giving the above warnings ? arr_ptr and &arr
both have the same types.