From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 21 17:03:03 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 331B216A4CE for ; Mon, 21 Feb 2005 17:03:03 +0000 (GMT) Received: from kane.otenet.gr (kane.otenet.gr [195.170.0.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 927DF43D45 for ; Mon, 21 Feb 2005 17:03:01 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b202.otenet.gr [212.205.244.210]) j1LH2pxP015750 for ; Mon, 21 Feb 2005 19:02:52 +0200 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.3/8.13.3) with ESMTP id j1LH2heK002289 for ; Mon, 21 Feb 2005 19:02:44 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.3/8.13.3/Submit) id j1LGxpK0002253; Mon, 21 Feb 2005 18:59:51 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 21 Feb 2005 18:59:51 +0200 From: Giorgos Keramidas To: Kathy Quinlan Message-ID: <20050221165951.GA2124@gothmog.gr> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4219C912.2070207@kaqelectronics.dyndns.org> X-Mailman-Approved-At: Tue, 22 Feb 2005 13:12:13 +0000 cc: freebsd-hackers@freebsd.org Subject: Re: Error in my C programming X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Feb 2005 17:03:03 -0000 On 2005-02-21 19:42, Kathy Quinlan wrote: > Peter Jeremy wrote: > > OK it was all to do with the comments it did not like the //comments > ARRGGHHHH the rest of the errors were bogus as soon as I changed EVERY > comment over to the ANSI C /*comments*/ it now works (oh and removed the > #pragma directives from a c compiler for the AVR uC I will have to put > all the different complier directives in different #ifdef tags :) 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 //. The correct way to invoke the C compiler in C99-mode depends, of course, on the compiler and it enables far more features than // comments. For GCC, the correct option to use is -std=c99. Using this program as a test, you can check for yourself (note that the comments of the sort shown in the following program are EXTREMELY bad style; they only serve as a test for //-style comments): $ cat -n foo.c 1 #include // For printf() 2 #include // For EXIT_SUCCESS 3 4 int 5 main(void) 6 { 7 printf("Hello C99 world\n"); // Print a message. 8 return (EXIT_SUCCESS); // Terminate program. 9 } Compiling in C89 mode (which does not allow // comments) gives: $ gcc -O -Wall -std=c89 foo.c foo.c:1:23: warning: extra tokens at end of #include directive foo.c:2:24: warning: extra tokens at end of #include directive foo.c: In function `main': foo.c:7: error: syntax error before '/' token $ Compiling in C99 mode, works as expected: $ gcc -O -Wall -std=c99 foo.c $ ./a.out Hello C99 world $