Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: using structures

Reply
Thread Tools

Re: using structures

 
 
Douglas A. Gwyn
Guest
Posts: n/a
 
      08-19-2003
Dave Hansen wrote:
> well, maybe not trivial, but simple -- to write a filter that converts
> "//" comments into the "/**/" form.


Indeed, I had to do that just before I left Geotronics,
because they were acquiring a VAX Unix system that didn't
support //-comments (which I had added support for in our
PDP-11 Unix compiler and preprocessor). I coded it as a
state machine; there were maybe a dozen states required.

> I agree, though, that any code that relies upon "//" comments will
> fail to compile on any C89-compliant implementation. And any
> implementation that accepts "//" comments is not C89-compliant.


Actually an implementation that accepts //-comments with
an advisory message such as "thanks for using // comments"
can be conforming *if* it handles the //* case correctly.

 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      08-19-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Dave Hansen) wrote in message news:<(E-Mail Removed)>...
> On 18 Aug 2003 10:57:58 -0700, (E-Mail Removed) (James Kuyper) wrote:
>
> >(E-Mail Removed) (Samuel Barber) wrote in message news:<(E-Mail Removed). com>...

> [...]
> >> ... Any
> >> compiler that doesn't accept "//" will fail to compile a large amount
> >> of C code.

> >
> >I believe that you're wrong; there's only a small, but increasing,
> >amount of C code that relies upon C99 features. However, I have no
> >good idea of how to prove that. It's more nearly correct to say the
> >reverse: Any code that relies upon "//" comments will fail to compile
> >on most C compilers.

>
> Of the various C compilers I've used between 1984 and the present,
> exactly two failed to support "//" comments. One was DEC C for
> VAX/VMS in 1984. The other was a version of gcc targetting the i960
> that accepted "//" without generating any warnings or errors, but
> generated faulty code.


I use two compilers at work. The IRIX compiler in default mode does
not accept "//".

The Gnu compiler (version 3.0.1) accepts it in default mode as an
extension to C90, but not in -ansi mode. The default meaning of -ansi
on that compiler is C90, not C99. It's C99 mode is not fully
conforming, even when all relevant options are selected appropriately.
Don't tell me that the newest version has different behavior; our
system is far from being the only one to be running a few years behind
on updates. Every compiler update is a major shakeup for our system,
and we therefore make updates only when we have to, just like a great
many other people.

> The "//" comment form has several advantages over the "/**/" form, and
> perhaps one disadvantage (backslash-newline continues the comment to
> the next line). It has appeared in much of the code I've worked on
> over the past 15 years, and not just code I wrote -- libraries, vendor
> examples, existing code at new job sites, etc. Furthermore, it is --
> well, maybe not trivial, but simple -- to write a filter that converts
> "//" comments into the "/**/" form.


It doesn't occur anywhere in any of the millions of lines of delivered
C code that constitute the project I work on. That may have something
to do with the fact that we're contractually obligated to provide C90
code. I doubt that we're the only contractor similarly constrained
by NASA's conservatism.
 
Reply With Quote
 
 
 
 
Ben Pfaff
Guest
Posts: n/a
 
      08-19-2003
Jan Engelhardt <(E-Mail Removed)> writes:

> Possibly an advantage of /**/:
> - it is supported in C++


So is //.
--
"I ran it on my DeathStation 9000 and demons flew out of my nose." --Kaz
 
Reply With Quote
 
Jan Engelhardt
Guest
Posts: n/a
 
      08-20-2003
>> Possibly an advantage of /**/:
>> - it is supported in C++

>
>So is //.


My rows meant: in C++ you have both, in C (per standard) only /**/.

--
- Jan Engelhardt
 
Reply With Quote
 
James Kuyper
Guest
Posts: n/a
 
      08-20-2003
Jan Engelhardt <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) qt.qr>...
> >> Possibly an advantage of /**/:
> >> - it is supported in C++

> >
> >So is //.

>
> My rows meant: in C++ you have both, in C (per standard) only /**/.


Incorrect: the C standard also allows //.

The previous version of the C standard didn't support it. Lots of
compilers still implementat the old standard by default. That is an
advantage of "/**/" over "//". Being supported by C++ is NOT an
advantage that "/**/" has over "//", since both of them are supported
by both C99 and C++.
 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      08-20-2003
James Kuyper wrote:

> Jan Engelhardt <(E-Mail Removed)> wrote in message news:<(E-Mail Removed) qt.qr>...
>
>>>>Possibly an advantage of /**/:
>>>>- it is supported in C++
>>>
>>>So is //.

>>
>>My rows meant: in C++ you have both, in C (per standard) only /**/.

>
>
> Incorrect: the C standard also allows //.
>
> The previous version of the C standard didn't support it. Lots of
> compilers still implementat the old standard by default. That is an
> advantage of "/**/" over "//". Being supported by C++ is NOT an
> advantage that "/**/" has over "//", since both of them are supported
> by both C99 and C++.


The obvious advantage in newgroups is that '/* ... */' comments don't get
munged.


--
Martin Ambuhl

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
structures, structures and more structures (questions about nestedstructures) Alfonso Morra C Programming 11 09-24-2005 07:42 PM
Xalan using generic DOM structures.. Ganesh Gella XML 7 11-10-2004 04:09 PM
Type Casting IPv4 and IPv6 structures to Generic Structures tweak C Programming 14 06-11-2004 02:43 PM
Re: Inheritance & polymorphism using C structures Vivek C++ 1 08-19-2003 10:55 AM
Re: Inheritance & polymorphism using C structures ES Kim C++ 0 08-19-2003 06:21 AM



Advertisments