473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

// vs /*

Hi,

Is using // for a comment standard C?

Thanks,
Joe
Jun 21 '06
59 3765
en******@yahoo.com writes:
Richard Heathfield wrote:
Joe Van Dyk said:
> Is using // for a comment standard C?


Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.


Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler. Or is this just more anti-C99
bias?


Suppose I download a large software package containing, say, several
hundred source files. It might even be in a mix of different
languages. Suppose I only have a strict C90 compiler that doesn't
support "//" comments. If the C code doesn't use "//" comments, I
just do the usual unpack, configure, make, make install (or whatever).
If it does, I can't compile it without editing the source files.
However easy that is for a single file, I'm not likely to take the
time to write something that will do it recursively for the whole
package (unless I *really* need to build and install the package).

(As it happens, I've never run into this particular situation myself.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jun 24 '06 #51
On 2006-06-24, en******@yahoo.com <en******@yahoo.com> wrote:

Richard Heathfield wrote:
Joe Van Dyk said:
> Hi,
>
> Is using // for a comment standard C?


Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.


Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler. Or is this just more anti-C99
bias?


Good point. Perhaps Mr Heathfield should also color-code his
work in HTML so that it will display better in web browsers.
After all, an experienced C programmer like himself could
easily write a filter to remove it come compile time. Or is
that just more anti-internet bias?

--
Andrew Poelstra < http://www.wpsoftware.net/blog >
To email me, use "apoelstra" at the above address.
I know that area of town like the back of my head.
Jun 24 '06 #52
en******@yahoo.com said:

Richard Heathfield wrote:
Joe Van Dyk said:
> Hi,
>
> Is using // for a comment standard C?
Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.


Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler.


Why would I need to write a filter? I don't put // comments into my source
in the first place! The place I encounter // comments most is right here in
comp.lang.c, in code written by people asking for help. If they want help
that badly, they can take the trouble to make their source compilable with
a C90 compiler.

Or is this just more anti-C99 bias?


Why would I be biased against something that, for most of us, doesn't even
exist? I am all in favour of C99 becoming as widespread as C90 currently
is. But until it gets to that stage, why would anyone interested in
portability bother to use it?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 24 '06 #53
On Sat, 24 Jun 2006 09:10:19 +0000, Richard Heathfield
<in*****@invalid.invalid> wrote:
en******@yahoo.com said:

Richard Heathfield wrote:
Joe Van Dyk said:

> Hi,
>
> Is using // for a comment standard C?

Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.


Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler.


Why would I need to write a filter? I don't put // comments into my source
in the first place!


Wow.

I have used // comments almost exlusively in my C code since 1996.
That was the year that Joe S. wrote a VC++ macro to format // comments
and I've been hooked ever since.

I love it that the compilers like gcc and VC++, inter alia, support //
comments in C90 code.

--
jay
Jun 24 '06 #54
jaysome said:

<snip>
I have used // comments almost exlusively in my C code since 1996.
That was the year that Joe S. wrote a VC++ macro to format // comments
and I've been hooked ever since.

I love it that the compilers like gcc and VC++, inter alia, support //
comments in C90 code.


You need to turn up your warning level.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jun 24 '06 #55
jaysome wrote:
Why would I need to write a filter? I don't put // comments into my source
in the first place!


Wow.

I have used // comments almost exlusively in my C code since 1996.
That was the year that Joe S. wrote a VC++ macro to format // comments
and I've been hooked ever since.

I love it that the compilers like gcc and VC++, inter alia, support //
comments in C90 code.


Try working on a non-windows platform for a change.

You'll get on some hard to pronounce box like AIX or HP-UX and do a

cc -V

and get "copyright 1994" as a response...

Then you'll compile your code except it explodes because // isn't a
valid C90 comment.

I don't see why /* */ is so hard to write. You really ought to be
spending more time thinking about what to put in the comment then the
delimitters.

Tom

Jun 24 '06 #56
On 2006-06-24, Tom St Denis <to********@gmail.com> wrote:
jaysome wrote:
>Why would I need to write a filter? I don't put // comments into my source
>in the first place!


Wow.

I have used // comments almost exlusively in my C code since 1996.
That was the year that Joe S. wrote a VC++ macro to format // comments
and I've been hooked ever since.

I love it that the compilers like gcc and VC++, inter alia, support //
comments in C90 code.


Try working on a non-windows platform for a change.

You'll get on some hard to pronounce box like AIX or HP-UX and do a

cc -V

and get "copyright 1994" as a response...

Then you'll compile your code except it explodes because // isn't a
valid C90 comment.

I don't see why /* */ is so hard to write. You really ought to be
spending more time thinking about what to put in the comment then the
delimitters.


Not to mention how much easier it is to format. I try to keep my comments
under a hundred characters or so (preferably 80, but space gets tight),
and typing /**/ and being able to fill that with whatever I want, including
newlines, is a big help.

jaysome:
gcc does not support // comments in c90 mode. Every time I compile with
them, I get diagnostics. Perhaps you should raise your warning level a
fair bit. It will help you write better C.

--
Andrew Poelstra < http://www.wpsoftware.net/blog >
To email me, use "apoelstra" at the above address.
I know that area of town like the back of my head.
Jun 24 '06 #57

Keith Thompson wrote:
en******@yahoo.com writes:
Richard Heathfield wrote:
Joe Van Dyk said:
Is using // for a comment standard C?

Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.
Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler. Or is this just more anti-C99
bias?

Suppose I download a large software package containing, say, several
hundred source files. It might even be in a mix of different
languages. Suppose I only have a strict C90 compiler that doesn't
support "//" comments. If the C code doesn't use "//" comments, I
just do the usual unpack, configure, make, make install (or whatever).
If it does, I can't compile it without editing the source files.
However easy that is for a single file, I'm not likely to take the
time to write something that will do it recursively for the whole
package (unless I *really* need to build and install the package).
Put yourself in the place of the author. If you wanted
to use // comments but still let people use strict C90
compilers, you (a) convert the // comments to /*...*/
comments before publishing, (b) include a small program
(integrated with the makefile that builds the package)
to take out the // comments automatically, or (c) simply
remove the // comments before publishing. If it were me
I'd probably pick (a) or (b), depending on the expected
audience.

On the other hand, if you didn't care about people who
only have strict C90 compilers, you wouldn't do anything,
and they'd be forced to fend for themselves. And that
should be your choice as the author -- they can either
find a way to process source with // comments, or not
use it. But then, how many people don't have an easy
way to compile C with // comments in it?
(As it happens, I've never run into this particular situation myself.)
My point is, if you did run into it, it's only about an
afternoon's worth of work to write a program that solves
the problem. And that's only if you can't set your
compiler to accept // comments.

Jul 17 '06 #58

Andrew Poelstra wrote:
On 2006-06-24, en******@yahoo.com <en******@yahoo.comwrote:

Richard Heathfield wrote:
Joe Van Dyk said:

Hi,

Is using // for a comment standard C?

Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.
Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler. Or is this just more anti-C99
bias?

Good point. Perhaps Mr Heathfield should also color-code his
work in HTML so that it will display better in web browsers.
After all, an experienced C programmer like himself could
easily write a filter to remove it come compile time. Or is
that just more anti-internet bias?
One of the sillier analogic arguments I've read.
Haven't you learned not to make arguments that
don't pass the laugh test?

Jul 17 '06 #59

Richard Heathfield wrote:
en******@yahoo.com said:

Richard Heathfield wrote:
Joe Van Dyk said:

Hi,

Is using // for a comment standard C?

Yes and no. Several reasons have been given for avoiding them in your C90
programs, but nobody appears to have mentioned the fact that modding down
ANSI conformance to allow them will, in some implementations, also
necessarily involve removing some other diagnostic messages. For example,
on the implementation I use most during development, enabling // comments
involves disabling a great many ANSI conformance checks. It's too high a
price.
Surely it's a simple matter for an experienced C
programmer such as yourself to write a small
program that filters them out and still lets you
use a C90 compiler.

Why would I need to write a filter? I don't put // comments into my source
in the first place! The place I encounter // comments most is right here in
comp.lang.c, in code written by people asking for help. If they want help
that badly, they can take the trouble to make their source compilable with
a C90 compiler.
A clever shift in topic. What we _were_ talking about
is how hard would it be to put // comments in your
C source (and still get the ANSI conformance checks
you want). The answer is, not very difficult. But
of course you don't want to admit that, you'd rather
change the topic.
Or is this just more anti-C99 bias?

Why would I be biased against something that, for most of us, doesn't even
exist? I am all in favour of C99 becoming as widespread as C90 currently
is. But until it gets to that stage, why would anyone interested in
portability bother to use it?
Of course C99 exists - it's available from ISO. What
you mean is _implementations_ of C99 don't exist (for many
people). If you choose to continue to be one of those
people, fine, but that doesn't mean other people should
want to make the same choice.

Jul 17 '06 #60

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.