Re: what is it for?

Discussion in 'C++' started by Old Wolf, Dec 5, 2005.

  1. Old Wolf

    Old Wolf Guest

    Kenneth Brody wrote:

    > wrote:
    >>
    >> Hello, I know what ifdef is used for, but I am not sure what these
    >> lines are for for compilation.
    >>
    >> #ifdef __cplusplus
    >> extern "C" {
    >> #endif

    >
    > This tells a C++ compiler that the following is C code, rather than C++.


    Actually it doesn't. If you are using a C compiler, the code will
    be treated as C, and if you are using a C++ compiler, the code
    will be treated as C++.

    This directive tells a C++ compiler to generate code that's
    compatible with its C ABI, so that C and C++ object files can
    subsequently be linked together. Examples of this include
    disabling name mangling, and maybe different calling
    conventions and structure padding.

    Finally, nothing in the C standard prevents a C compiler from
    defining __cplusplus, although only the DS9000 would do so.

    I've attempted to set follow-ups to comp.lang.c++, because this
    stuff is all part of C++ rather than C. I haven't done this before
    so I hope it turns out well...
     
    Old Wolf, Dec 5, 2005
    #1
    1. Advertising

  2. Old Wolf

    Eric Sosman Guest

    Old Wolf wrote On 12/05/05 17:12,:
    > [...]
    > Finally, nothing in the C standard prevents a C compiler from
    > defining __cplusplus, although only the DS9000 would do so.


    Section 6.10.8, paragraph 5:

    The implementation shall not predefine the
    macro __cplusplus, nor shall it define it in
    any standard header.

    > I've attempted to set follow-ups to comp.lang.c++, [...]


    You did it correctly, but I added c.l.c. back
    because the misteak should not stand unchallenged.

    --
     
    Eric Sosman, Dec 5, 2005
    #2
    1. Advertising

  3. "Old Wolf" <> writes:
    [...]
    > Finally, nothing in the C standard prevents a C compiler from
    > defining __cplusplus, although only the DS9000 would do so.


    Unless you count C99 6.10.7p5:

    The implementation shall not predefine the macro __cplusplus, nor
    shall it define it in any standard header.

    (An aside: when I did a copy-and-paste from n1124.pdf, the macro name
    showed up as "_ _cplusplus", which might make it difficult to find; I
    searched for just "cplusplus".)

    > I've attempted to set follow-ups to comp.lang.c++, because this
    > stuff is all part of C++ rather than C. I haven't done this before
    > so I hope it turns out well...


    It did, but I overrode the "Followup-To:" header for this article.

    --
    Keith Thompson (The_Other_Keith) <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.
     
    Keith Thompson, Dec 5, 2005
    #3
  4. Old Wolf

    pete Guest

    Eric Sosman wrote:

    > misteak


    .... so now I'm still hungry.

    ;)

    --
    pete
     
    pete, Dec 5, 2005
    #4
  5. On Mon, 05 Dec 2005 22:49:43 GMT, in comp.lang.c , Keith Thompson
    <> wrote:

    >"Old Wolf" <> writes:
    >[...]
    >> Finally, nothing in the C standard prevents a C compiler from
    >> defining __cplusplus, although only the DS9000 would do so.

    >
    >Unless you count C99 6.10.7p5:
    >
    > The implementation shall not predefine the macro __cplusplus, nor
    > shall it define it in any standard header.
    >
    >(An aside: when I did a copy-and-paste from n1124.pdf, the macro name
    >showed up as "_ _cplusplus", which might make it difficult to find; I
    >searched for just "cplusplus".)
    >
    >> I've attempted to set follow-ups to comp.lang.c++, because this
    >> stuff is all part of C++ rather than C. I haven't done this before
    >> so I hope it turns out well...

    >
    >It did, but I overrode the "Followup-To:" header for this article.


    Is there an echo in here?
    :)

    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
     
    Mark McIntyre, Dec 5, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page