Re: Why the compiler gives warning ?
- From: "Robert Gamble" <rgamble99@xxxxxxxxx>
- Date: 9 Aug 2005 05:17:51 -0700
junky_fellow@xxxxxxxxxxx wrote:
> 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.
Are you using a pre-ansi C compiler? Such compilers might generate
these types of warnings, see FAQ 6.12.
Robert Gamble
.
- References:
- Why the compiler gives warning ?
- From: junky_fellow
- Why the compiler gives warning ?
- Prev by Date: Re: string comparison
- Next by Date: Re: Why the compiler gives warning ?
- Previous by thread: Why the compiler gives warning ?
- Next by thread: Re: Why the compiler gives warning ?
- Index(es):
Relevant Pages
|