9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] C99 and you
@ 2006-10-05 18:32 Skip Tavakkolian
  2006-10-06  0:09 ` Bruce Ellis
  0 siblings, 1 reply; 6+ messages in thread
From: Skip Tavakkolian @ 2006-10-05 18:32 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 456 bytes --]

somebody had a question a couple of days ago.  i wonder if the declaration
was inside a switch or after a label?

in the example below, if the seemingly superfluous ';' (comments 1, and 2)
are removed, it is a syntax error.  also note the scope of the declaration
inside a switch (e.g. when argc==1)

explanation:	http://www.thescripts.com/forum/thread214730.html
reference: 	http://wwwold.dkuug.dk/jtc1/sc22/open/n2794/n2794.txt	(look for A.2.3)

[-- Attachment #2: c99test.c --]
[-- Type: text/plain, Size: 315 bytes --]

#include <u.h>
#include <libc.h>

main(int argc, char **argv)
{
	int i;

	switch (argc) {
	case 2:
		;	// 1
		int j = 1;
		print("argc = %d; j = %d\n", argc, j);
		break;
	case 1:
		j = 0;
		print("argc = %d; j = %d\n", argc, j);
		break;
	}

	int k;

 foo:
	;	// 2
	int l;

	exits(nil);
}

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-10-06 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-05 18:32 [9fans] C99 and you Skip Tavakkolian
2006-10-06  0:09 ` Bruce Ellis
2006-10-06  1:33   ` Skip Tavakkolian
2006-10-06  8:28   ` Charles Forsyth
2006-10-06  9:51     ` erik quanstrom
2006-10-06 16:00       ` Bruce Ellis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).