When is a statement an expression?

Henry Spencer henry at utzoo.uucp
Fri Apr 28 02:28:46 AEST 1989


To address the Subject line first, a statement is NEVER an expression in C.

In article <1043 at itivax.iti.org> scs at vax3.iti.org (Steve Simmons) writes:
>	a = if ( a == 1 )
>		12 ;
>	else
>		14 ;

This is an interesting construct, but it's not legal C.  Probably some
compiler writer's bright idea.

>We tried it out on all the C compilers we could find (BSD 4.3, Gould,
>UNIX-PC, gcc) and it fails.  But the error messages are quite cryptic
>(we like gcc: "parse error after 'a'") and largely don't address
>the real problem...

When you feed a compiler something that it considers gibberish, it's
fairly normal for the error messages to be a bit cryptic.
-- 
Mars in 1980s:  USSR, 2 tries, |     Henry Spencer at U of Toronto Zoology
2 failures; USA, 0 tries.      | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list