#ifdef __cplusplus

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Tobin

    #46
    Re: #ifdef __cplusplus

    In article <47FE67CA.13ABE 6C@spamcop.net> ,
    Kenneth Brody <kenbrody@spamc op.netwrote:
    >But this whole argument is silly. A conforming C90 implementation
    >could define __cplusplus, but it would be a stupid implementation and
    >people would reject it. You can find a whole host of things that the
    >standard doesn't prohibit, but which would make a compiler a laughing
    >stock.
    >Well, one could make an implementation to "stress test" C source code,
    >with things like making NULL not all-bits zero (perhaps even making
    >an all-bits-zero pointer a trap representation) , converting between
    >pointers and ints/longs and back resulting in invalid pointers, (is
    >it valid to have sizeof(void*) sizeof(long)?), returning pointers
    >in a different register than non-pointers, and so on.
    Some of those tests are, to some degree, plausible. There could be
    some reason for some system to behave like that. Some are less so.
    There are even more absurd possiblities, such as only accepting one
    particular program that reaches the various minimum implementation
    limits. Having a C90 implementation define __cplusplus is in the
    "completely absurd" category; no realistic implementation would do it
    on any platform, so there is no point having a stress test for it.

    It makes no more sense to write your program to accommodate such
    implementations than to allow for ones where addition sometimes
    doesn't work.

    -- Richard

    --
    :wq

    Comment

    • lawrence.jones@siemens.com

      #47
      Re: #ifdef __cplusplus

      Richard Tobin <richard@cogsci .ed.ac.ukwrote:
      >
      Having a C90 implementation define __cplusplus is in the
      "completely absurd" category; no realistic implementation would do it
      on any platform, so there is no point having a stress test for it.
      You'd think so, but back in the day, there was at least one real
      commercial compiler that #define'd __STDC__ as 1 before making *amy*
      other change required to conform to the ANSI C Standard! So equally
      strange things have happened.

      -Larry Jones

      It must be sad being a species with so little imagination. -- Calvin

      Comment

      Working...