[net.lang.c] "missing endif": Huh?Who?What?

lwe3207@acf4.UUCP (04/11/84)

Nf-From: acf4!lwe3207    Apr 21 11:50:00 1984


[Sorry, same message with bug-killer line]

The following file elicits the interesting response "missing endif" from cc.
Replacing *v/*w with (*v)/(*w) fixes it:

---
foo (v,w)
int *v, *w;
{	int k;
	k = *v/*w;		}
---

lwe3207@acf4.UUCP (04/21/84)

Nf-From: acf4!lwe3207    Apr 21 11:49:00 1984


The following file elicits the interesting response "missing endif" from cc.
Replacing *v/*w with (*v)/(*w) fixes it:

---
foo (v,w)
int *v, *w;
{	int k;
	k = *v/*w;		}
---

prisner@decwrl.UUCP (Jeff Prisner) (04/22/84)

	Clearly we didn't get the whole story from the author.  What was 
happening is that the pre-processor never found the end of the comment 	
which begins /*w ... 

					J Prisner
					Digital Western Research Lab

hennessy@nmtvax.UUCP (04/23/84)

The following code from the endif problem posted gives the same
bad results on out machine. (Vax 11/750 under 4.2BSD) 
>---
>foo (v,w)
>int *v, *w;
>{	int k;
>	k = *v/*w;		}
>---

However if the last line of code has a space between the '/' and
the '*' then the code compiles. This seems to be a parsing error
since to the best of my knowledge white space is ignored with the
exception of the old op= or =op problems that earlier C had. Is
this the same type of error? Mr. Ritche are you out there?

Sincerely;
Greg Hennessy
..ucbvax!unmvax!nmtvax!hennessy

john9@garfield.UUCP (John Rochester) (04/24/84)

<  To Eat, or not to Eat?  That is the question...  >

>	The following file elicits the interesting response "missing endif" from cc.
>	Replacing *v/*w with (*v)/(*w) fixes it:
>	
>	---
>	foo (v,w)
>	int *v, *w;
>	{	int k;
>		k = *v/*w;		}
>	---

The problem is that the /* between the v and the w starts a comment...

			John Rochester
			{allegra,ihnp4,philabs,utcsrgv}!garfield!john9

per@erix.UUCP (Per Hedeland) (04/26/84)

<>

Obviously, the compiler thinks that the /* starts a comment (which may be
a bad thing), but why on earth should it say "missing endif" instead of
"missing end of comment"? Oh well, I never trust the error messages from
the C compiler very much anyway...

Per Hedeland

emjej@uokvax.UUCP (04/26/84)

#R:acf4:-1390000100:uokvax:3000023:000:637
uokvax!emjej    Apr 26 09:15:00 1984

/***** uokvax:net.lang.c / acf4!lwe3207 /  6:44 am  Apr 22, 1984 */
The following file elicits the interesting response "missing endif" from cc.
Replacing *v/*w with (*v)/(*w) fixes it:

---
foo (v,w)
int *v, *w;
{	int k;
	k = *v/*w;		}
---
/* ---------- */

The preprocessor thinks that the /* in *v/*w is the beginning of a comment,
and eliminates the rest of the code. I don't know why the "missing endif"
shows up; indeed, the version of the C compiler I had the misfortune to use
a while back didn't give a missing endif message, and cheerfully passed on
an empty file to the C compiler, which didn't mind a bit.

						James Jones

sander@aecom.UUCP (04/27/84)

	I don't know why it should pick "missing endif"; but that construct
is just asking for trouble:
				*v/*w
contains '/*', and so the rest of your program disapears into a non-terminated
comment. It always pays to stick in a few spaces:
				*v / *w
will work fine, and easier for both compilers and humans to read.
-- 
					Jeremy Sanders
 {spike|rocky2|philabs|pegasus|esquire|cucard}!aecom!{sanders|jsanders|sander}