Single Lines In C Comments

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

  1. macrumors regular

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

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

    Jul 8, 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.
  3. thread starter macrumors regular

    Jul 19, 2012
    Ok, thank you, I understand now. I haven't actually ever used anything besides C99
  4. macrumors 6502

    Madd the Sane

    Nov 8, 2010
  5. thread starter macrumors regular

    Jul 19, 2012
    C++ when it was invented in 78 at Bell, or C++98
  6. macrumors 604

    Aug 9, 2009
    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. macrumors 6502


    Feb 18, 2004
    Wilmington, DE
    They originally came from BCPL, which was also the first brace programming language. But, this is just esoteric trivia.
  8. thread starter macrumors regular

    Jul 19, 2012
    I was just curious but thank you.

Share This Page