Single Lines In C Comments

Discussion in 'Mac Programming' started by Marjamrob1, Jan 29, 2013.

  1. Marjamrob1
    Expand Collapse
    macrumors regular

    Joined:
    Jul 19, 2012
    #1
    When reading an older development book, I found this:

    However I have written C programs, that use "//" single line comments.
     
  2. ytk
    Expand Collapse
    macrumors regular

    Joined:
    Jul 8, 2010
    #2
    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.
     
  3. Marjamrob1
    Expand Collapse
    thread starter macrumors regular

    Joined:
    Jul 19, 2012
    #3
    Ok, thank you, I understand now. I haven't actually ever used anything besides C99
     
  4. Madd the Sane
    Expand Collapse
    macrumors 6502

    Madd the Sane

    Joined:
    Nov 8, 2010
    Location:
    Utah
  5. Marjamrob1
    Expand Collapse
    thread starter macrumors regular

    Joined:
    Jul 19, 2012
    #5
    C++ when it was invented in 78 at Bell, or C++98
     
  6. chown33
    Expand Collapse
    macrumors 604

    Joined:
    Aug 9, 2009
    #6
    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.
     
  7. ElectricSheep
    Expand Collapse
    macrumors 6502

    ElectricSheep

    Joined:
    Feb 18, 2004
    Location:
    Wilmington, DE
    #7
    They originally came from BCPL, which was also the first brace programming language. But, this is just esoteric trivia.
     
  8. Marjamrob1
    Expand Collapse
    thread starter macrumors regular

    Joined:
    Jul 19, 2012
    #8
    I was just curious but thank you.
     

Share This Page