Hi, Alan,

On Jan 21, 2010, at 22:39 , Alan W. Irwin wrote:

>> I certainly find the // comments convenient, but I recently ran  
>> into a small annoyance on a project with a manually maintained  
>> Makefile.  I found that I needed to use the gcc compiler option...
>>
>> -std=gnu99
>>
>> ...in order to be able to use // comments and some other "basics"  
>> like usleep and getopt.
>
> I just did a test of a // comment with gcc (without any special  
> options),
> and it compiled fine.  Could you try to confirm that for your version
> of gcc as well?

Yes, it recognizes // comments fine with no -std option, but then it  
gives a warning about round().  Using -std=c99 (as indicated by "man  
3 round") then gives a warning about usleep().  Using -std=gnu99 gets  
it all to work.  FWIW, this is with gcc 4.1.2 on CentOS 5.3.

$ gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There  
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR  
PURPOSE.

$ cat foo.c
#include <unistd.h>
#include <math.h>

#ifndef NO_COMMENT
// Test usleep and round functions
#endif
double foo(double x)
{
   usleep(1);
   return round(x);
}

$ gcc -c -o /dev/null foo.c
foo.c: In function 'foo':
foo.c:8: warning: incompatible implicit declaration of built-in  
function 'round'

$ gcc -std=c89 -c -o /dev/null foo.c
foo.c:5: error: expected identifier or '(' before '/' token

# ifndef out the // comment
$ gcc -std=c89 -DNO_COMMENTS -c -o /dev/null foo.c
(no complaints, but no // comments either)

$ gcc -std=c99 -c -o /dev/null foo.c
foo.c: In function 'foo':
foo.c:7: warning: implicit declaration of function 'usleep'

$ gcc -std=gnu99 -c -o /dev/null foo.c
(no complaints and with // comments!)

I should note that gcc 4.3.4 (on my Mac, installed via macports)  
compiles the above foo.c without any -std options (and with the //  
comments).

Like I said earlier, I think cmake should be able to handle any  
compiler specific issues, so I don't think my whining about this  
should dissuade you from changing to // comments.

Dave


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to