Does your C compiler support "//"? (was Re: using structures)

S

Samuel Barber

Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

Compiler? Microsoft 32-bit
Supports "//"? Yes
When? Unknown, at least since 1995.

Compiler? SAS/C for Amiga
Supports "//"? Yes
When? Unknown, at least since 1992.

Note: We're talking about the default mode of operation. It is
understood that some compilers have a "strict ANSI" option which may
disable "//" (among other things).

Sam
 
M

MW Ron

Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

Compiler? Microsoft 32-bit
Supports "//"? Yes
When? Unknown, at least since 1995.

Compiler? SAS/C for Amiga
Supports "//"? Yes
When? Unknown, at least since 1992.

Note: We're talking about the default mode of operation. It is
understood that some compilers have a "strict ANSI" option which may
disable "//" (among other things).

Metrowerks CodeWarrior compilers do support the // unless ANSI strict is
turned on.

Ron

--
CodeWarrior Development Studio for Macintosh v9
Enhance Your Productivity and Shorten your Development Cycles
<http://store.metrowerks.com/>
Sales and Support 512-996-5300 800-377-5416
Ron Liechty - (e-mail address removed) - http://www.metrowerks.com
 
D

Dave Vandervies

Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

Compiler: gcc -W -Wall -ansi -pedantic -O
Support "//": No.

Note: We're talking about the default mode of operation. It is
understood that some compilers have a "strict ANSI" option which may
disable "//" (among other things).

I don't understand. The default mode of operation for my compiler of
choice is strict ANSI, while the same compiler program is capable of
acting as a "less strict" compiler (or even as a compiler for a completely
different language[1]) when invoked differently.


dave

[1] Yes, C++ too, but the completely different language I'm thinking of
(Java) is an even more completely different language than C++.
 
P

Paul D. Smith

%% (e-mail address removed) (Dave Vandervies) writes:

dv> Compiler: gcc -W -Wall -ansi -pedantic -O
dv> Support "//": No.

Compiler: gcc -W -Wall -std=c99 -pedantic -O
Support "//": Yes.

Note -ansi is the same thing as -std=c89.

dv> I don't understand. The default mode of operation for my compiler
dv> of choice is strict ANSI,

It's not the "default mode of operation" if you have to add special
flags to make it operate that way. It may be the "default way you
invoke it", but that's not the same thing.

dv> while the same compiler program is capable of acting as a "less
dv> strict" compiler (or even as a compiler for a completely different
dv> language[1]) when invoked differently.

Well, given the correct flags you can make your compiler act as a
"strict K&R", too... ??

I'm not sure what the point there is: the original question was, I
suspect, along the lines of "I know not many, if any, compilers support
all of c99 yet, but how many at least support the C++-style comments
feature of c99 in their default mode of operations?"

--
 
I

Ivan Vecerina

| In article <[email protected]>,
....
| >The question is simple: does your C compiler (or compilers) support
| >"//"? Name the compiler(s), and if possible indicate when the feature
| >was added.
|
| Compiler: gcc -W -Wall -ansi -pedantic -O
| Support "//": No.

Anything against adding: -std=c99 ?

Unless you have a requirement for portability to older compilers, it
is ok IMHO to rely on features of the new C standard that are already
widely supported by current compilers (e.g. //, const, restrict, ...).

The only drawback being, on some implementations, that it forces you
to loosen some standards-conformance checks. Not the case w/ GCC though.


Regards,
Ivan
 
A

Al Grant

Jack Klein said:
Visual C++ and any other compiler that supports that one is just plain
flat out wrong.

Did you try it on Visual C++?
Even if a compiler reversed the order of these two operations, the '\'
at the end of the line would not cause a splice because it was not
immediately before the newline.

So there have to be two different things broken in a compiler to
accept this. It must replace comments before line splicing, and it
must either remove comments without replacing them with a space
character, or ignore extraneous white space characters between the '\'
and newline.

Or it just defines phase 1 such that an "end-of-line indicator"
can absorb trailing whitespace and comments (or things that look
like comments). This would be no more illegal than, say, ignoring
columns 73 to 80 in sources that were in card image format.
 
R

Richard Kettlewell

Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

$ type cc
cc is hashed (/bin/cc)
$ uname -a
IRIX64 slough 6.5 11051212 IP27 mips
$ cat t.c
// does it work?
$ cc -c t.c
"t.c", line 1: error(1166): expected a declaration
// does it work?
^

1 error detected in the compilation of "t.c".

I see no option to make the IRIX compiler accept // comments.

$ type cc
cc is hashed (/usr/vac/bin/cc)
$ uname -a
AIX faslane 1 5 0052906A4C00 unknown
$ cat t.c
// does it work?
$ cc -c t.c
"t.c", line 1.1: 1506-046 (S) Syntax error.
"t.c", line 1.4: 1506-166 (S) Definition of function does requires parentheses.

In this case there is an option to support // comments (which we don't
enable). I've no idea when it was added.
 
J

Jan Engelhardt

The question is simple: does your C compiler (or compilers) support
$ type cc
cc is hashed (/bin/cc)
$ uname -a
IRIX64 slough 6.5 11051212 IP27 mips
$ cat t.c
// does it work?
$ cc -c t.c
"t.c", line 1: error(1166): expected a declaration
// does it work?
^

1 error detected in the compilation of "t.c".

In this case there is an option to support // comments (which we don't
enable). I've no idea when it was added.

cc -version (or similar) might have been helpful too. Anyway, "screwed":

c:\tcpp>which tcc
c:\tcpp\bin\tcc.exe (in PATH)
c:\tcpp>echo "// huh" >new.c
c:\tcpp>tcc new.c
it didnot complain. and btw, my tcc version is 1989/90.
But that it accepts // is probably just because tcc also compiles
c++ code.
 
D

Dan Pop

In said:
| In article <[email protected]>,
...
| >The question is simple: does your C compiler (or compilers) support
| >"//"? Name the compiler(s), and if possible indicate when the feature
| >was added.
|
| Compiler: gcc -W -Wall -ansi -pedantic -O
| Support "//": No.

Anything against adding: -std=c99 ?

It would render gcc non-conforming according to both C89 and C99
standards.

Dan
 
J

James Kuyper

Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added. ....
Note: We're talking about the default mode of operation. It is
understood that some compilers have a "strict ANSI" option which may
disable "//" (among other things).

Who is "We", kemosabe?

I'm talking about compilers that conform to an ANSI/ISO C standard,
using the appropriate options (such as -ansi), if necessary to put
them into conforming mode. In my experience, most such compilers
implement C90, unless you specifically request C99 conformance. And on
many compilers, a fully C99-conformant mode is still unavailable. I've
heard of fully-conformant C99 compilers, but I've never used one.
 
S

Serve La

Samuel Barber said:
Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

lccwin32 has them, the oldest source file I have with that compiler is from
2-8-2000.
The code is full of // comments
 
K

Keith Thompson

Martin Dickopp said:
The "default mode of operation" for gcc as a C compiler would be
`gcc -std=c89'. Without `-std=c89' (or `-ansi'), gcc is a compiler
for a language called `GNU C', which is totally unrelated to C.

The point is well taken, but I think "totally unrelated to C" is an
exaggeration. I'd say that "GNU C" is very closely related to C.
 
S

Scott Condit

Martin said:
The "default mode of operation" for gcc as a C compiler would be
`gcc -std=c89'. Without `-std=c89' (or `-ansi'), gcc is a compiler
for a language called `GNU C', which is totally unrelated to C.

By the same token, do you consider C89 and C99 to also be "totally
unrelated"?

S
 
R

Randy Howard

Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

The cc for Dell UNIX SVR4 (P/N 17993, Rev A01) does not support such
comments. I'm fairly sure than none of the cc's for any of the
Intel-based System V Release 3.2 or 4 releases does so either but
I haven't tested them all.

The Power C (MIX Software) compiler for MS-DOS (16-bit) doesn't either.

What about the Microsoft 16-bit DOS/Win16 compiler MSVC 1.52? I don't
have it installed right now, but I don't recall if it does or does not
support them.

The Metrowerks cross-compiler for Novell (the festering heap that it is)
does support them, but only when not in "strict" mode.
 
M

Martin Dickopp

Keith Thompson said:
The point is well taken, but I think "totally unrelated to C" is an
exaggeration.

You are correct, of course. I sometimes tend to (deliberately) exaggerate.
:)

My point was that gcc, if invoked without any flags, does not even claim to
implement C as defined by any ISO standard or pre-C89 de facto standard
(K&R).

Martin
 
M

Martin Dickopp

Scott Condit said:
By the same token, do you consider C89 and C99 to also be "totally
unrelated"?

Absolutely. I consider C89 and C99 about as related as C89 and GNU C.
;))

Martin
 
J

Jack Klein

Did you try it on Visual C++?


Or it just defines phase 1 such that an "end-of-line indicator"
can absorb trailing whitespace and comments (or things that look
like comments). This would be no more illegal than, say, ignoring
columns 73 to 80 in sources that were in card image format.

It seems to me that the wording of the description for phase 3 does
not give an implementation the right to merely discard space
characters.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
P

Paul D. Smith

md> My point was that gcc, if invoked without any flags, does not even
md> claim to implement C as defined by any ISO standard or pre-C89 de
md> facto standard (K&R).

Well, I'm pretty sure that it implements a superset of C. That is, if
you have a conforming C program, GCC will properly compile it.

If you don't have a conforming C program, then you might not get
required diagnostics (although your code still may work as you intended)
since GCC-with-no-flags supports several extensions to standard C.

--
 
C

CBFalconer

Samuel said:
Since my contension that "//" comments are acceptable in contemporary
C code has generated some controversy (with some people asserting that
only "a few" compilers support it), let's have an informal poll.

The question is simple: does your C compiler (or compilers) support
"//"? Name the compiler(s), and if possible indicate when the feature
was added.

Compiler? Microsoft 32-bit
Supports "//"? Yes
When? Unknown, at least since 1995.

Compiler? SAS/C for Amiga
Supports "//"? Yes
When? Unknown, at least since 1992.

Note: We're talking about the default mode of operation. It is
understood that some compilers have a "strict ANSI" option which may
disable "//" (among other things).

Since I run gcc through the following 4dos alias (one line), my
default is to not accept // comments.

IFF ".%1." == ".." THEN ^ *gcc --help ^ ELSE ^ *gcc -W -Wall
-ansi -pedantic -Wwrite-strings -gstabs+ -O1 %1& ^ ENDIFF

Compiler? GCC via alias
Supports "//"? No.

AFAIK I cannot make gcc accept \\ comments and still check full
standards conformance. Thus your specification of 'default' is
faulty, since default is whatever the installation wants.
 
R

Ross Ridge

Martin Dickopp said:
The "default mode of operation" for gcc as a C compiler would be
`gcc -std=c89'. Without `-std=c89' (or `-ansi'), gcc is a compiler
for a language called `GNU C', which is totally unrelated to C.

Keith Thompson said:
The point is well taken, but I think "totally unrelated to C" is an
exaggeration. I'd say that "GNU C" is very closely related to C.

I'd say "GNU C" is C. It's as much C as any other dialect of C, including
including Standard C. Well, that is, including the "strictly conforming
program" dialect of Standard C. The standard itself alloww for of other
compatible and conforming dialects of C.

Ross Ridge
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top