Re: Keil c51 interprets &Array as Array. Is that normal?



On Thu, 10 Apr 2008 12:57:46 -0700, Andrey Tarasevich wrote:

Tim Wescott wrote:

Yes it is a pointer to an array of 10 chars. No it is not a pointer to
char. There _is_ a difference, but the compiler is well aware of it
and will seamlessly cast from pointer-to-array-of-N-char to
pointer-to-char.


Absolutely not. A C compiler in a relaxed diagnostics mode might allow
something like this, since C compilers by default are traditionally very
forgiving when it comes to pointer casts. However, such a conversion is
illegal from the language point of view. Any half-decent C compiler will
normally issue at least a warning about broken assignment.

Eh? Perhaps I didn't state that correctly.

char a[10];
char * b;

....

b = a; // compiles just fine

--
Tim Wescott
Control systems and communications consulting
http://www.wescottdesign.com

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott
Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
.