Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 29, 2013, 02:19 PM   #1
Marjamrob1
macrumors regular
 
Join Date: Jul 2012
Single Lines In C Comments

When reading an older development book, I found this:

Quote:
You may also hear multi-line comments being described as 'C-Style' comments because the /*...*/ is the only one available for creating comments in the C language.
However I have written C programs, that use "//" single line comments.
Marjamrob1 is offline   0 Reply With Quote
Old Jan 29, 2013, 02:32 PM   #2
ytk
macrumors regular
 
Join Date: Jul 2010
Originally, the only style for commenting in C was /* ... */. This is still the case in C89, which is traditionally known as ANSI-C. C99 added support for one line comments using //. If your book was written before the C99 standard was approved, it was correct at the time, and still is for older systems.
ytk is offline   2 Reply With Quote
Old Jan 29, 2013, 02:37 PM   #3
Marjamrob1
Thread Starter
macrumors regular
 
Join Date: Jul 2012
Ok, thank you, I understand now. I haven't actually ever used anything besides C99
Marjamrob1 is offline   0 Reply With Quote
Old Feb 3, 2013, 02:53 PM   #4
Madd the Sane
macrumors 6502
 
Join Date: Nov 2010
Location: Utah
// comments originally came from C++, IIRC.
Madd the Sane is online now   0 Reply With Quote
Old Feb 4, 2013, 08:15 PM   #5
Marjamrob1
Thread Starter
macrumors regular
 
Join Date: Jul 2012
Quote:
Originally Posted by Madd the Sane View Post
// comments originally came from C++, IIRC.
C++ when it was invented in 78 at Bell, or C++98
Marjamrob1 is offline   0 Reply With Quote
Old Feb 4, 2013, 08:41 PM   #6
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by Marjamrob1 View Post
C++ when it was invented in 78 at Bell, or C++98
Why does it matter?


There was a period of time when the C compilers used by Apple accepted // comments even though it wasn't in the ANSI/ISO C standard of the time. There was a command-line option for strict C conformance that would turn this off, so // was forbidden. IIRC, there was another option that would force strict compliance to the ISO C standard, EXCEPT that // comments were allowed. Other than as a historical footnote, none of this matters today, and hasn't since C99.
chown33 is offline   0 Reply With Quote
Old Feb 4, 2013, 09:48 PM   #7
ElectricSheep
macrumors 6502
 
Join Date: Feb 2004
Location: Wilmington, DE
Send a message via AIM to ElectricSheep
Quote:
Originally Posted by Madd the Sane View Post
// comments originally came from C++, IIRC.
They originally came from BCPL, which was also the first brace programming language. But, this is just esoteric trivia.
__________________
15'' MBP (early 2011) | i7 3770k Hackintosh | i7 Mac Mini (late 2012) | iPhone 5 | iPad 3 (2012) | iPad mini | MacOS X 10.9.2
ElectricSheep is offline   0 Reply With Quote
Old Feb 5, 2013, 04:09 PM   #8
Marjamrob1
Thread Starter
macrumors regular
 
Join Date: Jul 2012
Quote:
Originally Posted by chown33 View Post
Why does it matter?


There was a period of time when the C compilers used by Apple accepted // comments even though it wasn't in the ANSI/ISO C standard of the time. There was a command-line option for strict C conformance that would turn this off, so // was forbidden. IIRC, there was another option that would force strict compliance to the ISO C standard, EXCEPT that // comments were allowed. Other than as a historical footnote, none of this matters today, and hasn't since C99.
I was just curious but thank you.
Marjamrob1 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump


All times are GMT -5. The time now is 02:22 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC