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 offline   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

Similar Threads
thread Thread Starter Forum Replies Last Post
Anyone went from a 5 to a 5C - comments pls MrMister111 iPhone 19 Dec 10, 2013 05:21 PM
All iPads: iPad Launch Day Lines vs. iPhone Launch Day Lines TAI182 iPad 5 Oct 7, 2013 06:29 AM
Spotlight comments? shawnperson OS X 10.8 Mountain Lion 4 Apr 30, 2013 07:22 PM
Mac Pro 5,1: Single cpu = Single socket? zopiro Mac Pro 5 Oct 28, 2012 05:37 PM
Comments and Criticism please! adamvk Design and Graphics 37 Jul 26, 2012 01:56 AM

Forum Jump

All times are GMT -5. The time now is 07:43 PM.

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

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