On Mon, Jul 02, 2001, Shachar Shemesh wrote about "Re: (main_buf = *main_buf_p) is not
syntacticly like (i = *j) ?":
> Nadav Har'El wrote:
>
> >Which means the jmp_buf type is an array. In C you can't normally assign
> >arrays like you did (because C thinks you're trying to assign pointers, rather
> >than the content of the array), so either do
> >
>
> Slight correction. I know I lost a bet over this, and I know many people
> make this mistake.
>
> The compiler doesn't view arrays as pointers. Arrays and pointers are
> distinct things in C. They are easily castable one into the other, hence
> the common misconception, but they are defenitely distinct.
I know very well the difference between arrays and pointers in C, and I
don't think I said anything wrong. Take a look at Dennis Ritchie's "The
Development of the C Language" for how the confusion of pointers and arrays
came about, and why it's a feature, not a bug :)
It's in http://cm.bell-labs.com/cm/cs/who/dmr/chist.html or
http://cm.bell-labs.com/cm/cs/who/dmr/chist.pdf.
Anyway, I wasn't saying that these were pointers. In fact, if they were,
they were assignable, and the whole thing would work. But I meant was:
When C sees an array on the right hand of an assignment, it treats it as a
pointer, which is why you can do something like
char *p, s[7];
p=s;
But when it sees an array on the left hand side of the assignment (like the
original poster used), it barfs. It should complain that the left-hand side
of the assignment is not assignable (in compiler-speak, not an lvalue),
and indeed Solaris's compiler says:
"z.c", line 8: left operand must be modifiable lvalue: op "="
But gcc's compiler prints the much less clear "incompatible types in
assignment". It might be because it first converts the right-hand-side
to a pointer, but of course cannot do the same for the left-hand-side of
the assignment, and then sees it cannot assign a pointer to an array.
--
Nadav Har'El | Monday, Jul 2 2001, 11 Tammuz 5761
[EMAIL PROTECTED] |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Hospitality: Making your guests feel at
http://nadav.harel.org.il |home, even if you wish they were.
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]