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

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

Need to learn how to apply control theory in your embedded system?
"Applied Control Theory for Embedded Systems" by Tim Wescott

Relevant Pages

  • Re: C needs to grow up a little, move with the times, expand its horizons
    ... float myFunction(int a, char* c); ... The compiler would look for the "myFunction" by name, ... If that isn't mangling, what is it? ... RDC will not go further than pointer to pointers. ...
  • Re: TEA Implementation
    ... The second argument should be a pointer to pointer to ... It should be the address of a pointer to char. ... compiler won't even accept it at all. ... Seems like a rather confusing way of writing ...
  • Re: large files: when ubiquitous?
    ... the pointer might be into shared ... compiler will make optimizations giving unexpected ... same with and without optimization, ... to a char pointer type or changing p to be a char ...
  • Re: lvalue assignment error
    ... > char *sstrdup ... convert the char pointer to a void pointer automatically, no cast ... compiler is forced to assume that it returns an int. ...
  • Re: How to convert Infix notation to postfix notation
    ... and make all strings const save where the intent ... function whose contract is to change the string. ... the compiler "just" prevents the string ... try to do using the pointer you get. ...