Date: Tue, 22 Feb 2005 15:21:33 +0100 From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: Kathy Quinlan <kat-free@kaqelectronics.dyndns.org> Subject: Re: Error in my C programming Message-ID: <86is4kad5e.fsf@xps.des.no> In-Reply-To: <20050221165951.GA2124@gothmog.gr> (Giorgos Keramidas's message of "Mon, 21 Feb 2005 18:59:51 %2B0200") References: <4218B960.1050403@kaqelectronics.dyndns.org> <20050220183219.GK57256@cirb503493.alcatel.com.au> <4218DEC5.1080600@kaqelectronics.dyndns.org> <20050221065844.GB81063@cirb503493.alcatel.com.au> <4219C912.2070207@kaqelectronics.dyndns.org> <20050221165951.GA2124@gothmog.gr>
index | next in thread | previous in thread | raw e-mail
Giorgos Keramidas <keramida@ceid.upatras.gr> writes:
> The quotations seem a bit messed up, so I don't know if Peter Jeremy or
> Kathy Quinlan wrote the above paragraph. Whoever the author was though,
> it may be worth to note that C99 *does* allow single-line comments
> delimited by //.
which leads to the following code being well-formed and well-defined
in both C89 and C99 but having different semantics...
#include <stdio.h>
int
main(void)
{
int a, b, c;
a = 10;
b = 2;
c = a //* oops! */
-b;
switch (c) {
case 8:
printf("C99 or C++\n");
break;
case -5:
printf("C89\n");
break;
default:
printf("can't happen\n");
break;
}
return 0;
}
This is actually documented in the C99 rationale.
DES
--
Dag-Erling Smørgrav - des@des.no
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86is4kad5e.fsf>
