Topic: Standard C++ Macro


Author: jcoffin@rmii.com (Jerry Coffin)
Date: 1995/12/09
Raw View
chris.dearlove@gecm.com (Chris Dearlove) wrote:

>Jerry Coffin (jcoffin@rmii.com) wrote:

>: It's a tautology that the standard has no control over non-standard
>: compilers...

>Whilst not disagreeing with you about the actual position I have
>wondered before whether ANSI could have trademarked something like
>__STDC__ and then licensed its general use to vendors who made a
>reasonable atempt to be compliant. Mind you even if legal this could
>and I guess would) have caused more problems than it solved, especially
>if use required payment.

Hmm...well, I suspect it actually could be done, though I'd tend to
leave the licensing part up to the individual certifying bodies instead
of the standards bodies.  I.e. in the US it would be NIST, and could
simply go along with NIST certification of compliance.  There is a
charge for certification, but as closely as I recall, it's not terribly
expensive. (In the vacinity of $100 or so...)

Now that you mention it, this isn't a lot different from what the DoD
did with Ada for quite a while -- you could only legally use the name
Ada (at least in the US) if your compiler had been tested.  If it hadn't
passed, you had to include a statement that you were working toward full
compliance.
    Later,
    Jerry.

/* I can barely express my own opinions; I certainly can't
 * express anybody else's.
 *
 * The universe is a figment of its own imagination.
 */



---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: bkline@cortex.nlm.nih.gov (Bob Kline)
Date: 1995/11/30
Raw View
The C standard specifies the name __STDC__ as the official way to indicate
support for the standard.  Unfortunately, of course, in practice all you
get is an indication that the vendor claims compliance.

Amol_Khedkar@bocagate.bocaraton.ibm.com wrote:
: In <4998dt$j01@newsbf02.news.aol.com>, krishtere@aol.com (Krishtere) writes:
: >OK, perhaps this is a stupid question and its there as plain as day in
: >front of me but...
: >
: >In the ANSI C std there is a macro something like _STD_C_ which could be
: >used to determine if the compiler was ANSI-compliant:
: >
: >#ifdef _STD_C_
: >/*  stuff  that requires ANSI-compliance */
: >#endif
: >
: [text deleted]

: I don't believe that ANSI dictates the existence of such a macro. I could be
: wrong on this one. However, if I remember correctly, MS C 6.0 defined a macro
: __STDC__ and IBM C-Set++ defines one called __ANSI__. I believe this varies
: with the compiler that you're using. Check the compiler documentation.

: Hope this helped!

: Cheers!

: -- Amol.

--
/*----------------------------------------------------------------------*/
/* Bob Kline                                       Stream International */
/* bob_kline@stream.com               formerly Corporate Software, Inc. */
/* voice: (703) 522-0820 x-311                      fax: (703) 522-5407 */
/*----------------------------------------------------------------------*/

---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: Sean A Corfield <sean@corf.demon.co.uk>
Date: 1995/11/30
Raw View
In article <49h73m$lrp@natasha.rmii.com>,
jcoffin@rmii.com (Jerry Coffin) wrote:

|> The C standard requires that __STDC__ be defined to the value 1.
|>
|> According to C++PL2, whether __STDC__ is defined by a C++ compiler, and
|> if so what value it has, are implementation dependent.
...
|> I can find nothing similar required of a conforming implementation of
|> C++ -- perhaps the committee figures there will never actually be a
|> conforming implementation. <GD&R>

Interestingly (or not) there's nothing to prevent a NON-conforming C
compiler from predefining __STDC__ to be 1! I recall a well-known compiler
which predefined __STDC__ as zero (unless in ansi compliant mode) -- this
wreaked havoc with code that simply had:

  #ifdef __STDC__
  /* oh, good, it's a conforming compiler! */
  #endif

The C++ draft requires __cplusplus to be predefined but sensibly, IMO,
does not attempt to overspecify conformance the way ISO C attempted.

Sean A. Corfield
Object Consultancy Services
C++ - Beyond the ARM - http://uptown.turnpike.net/~scorf/cplusext.html


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]






Author: kanze@gabi-soft.fr (J. Kanze)
Date: 1995/12/01
Raw View
Jerry Coffin (jcoffin@rmii.com) wrote:
|> Amol_Khedkar@bocagate.bocaraton.ibm.com wrote:

|> [ ... ]

|> >>#ifdef _STD_C_
|> >>/*  stuff  that requires ANSI-compliance */
|> >>#endif
|> >>
|> >[text deleted]

|> >I don't believe that ANSI dictates the existence of such a macro. I could be
|> >wrong on this one. However, if I remember correctly, MS C 6.0 defined a macro
|> >__STDC__ and IBM C-Set++ defines one called __ANSI__. I believe this varies
|> >with the compiler that you're using. Check the compiler documentation.

|> The C standard requires that __STDC__ be defined to the value 1.

Of course, the C standard only makes requirements concerning standard
conforming compilers.  It has nothing to say about compilers which do
not conform to the standard.  In particular, such a compiler could also
define __STDC__ as 1.

In fact, of course, this is generally the case.  A compiler with defects
generally fails to conform because of those defects.  This includes all
of the so-called ANSI C compilers that I've tried, and they all still
define __STDC__ as 1.

This is not to belittle ANSI's adopting this definition; it is just a
warning to beware.  Read your compiler's documentation, and experiment.
--
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils,    tudes et r   alisations en logiciel orient    objet --
              -- A la recherche d'une activit    dans une region francophone


---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: krishtere@aol.com (Krishtere)
Date: 1995/11/26
Raw View
OK, perhaps this is a stupid question and its there as plain as day in
front of me but...

In the ANSI C std there is a macro something like _STD_C_ which could be
used to determine if the compiler was ANSI-compliant:

#ifdef _STD_C_
/*  stuff  that requires ANSI-compliance */
#endif

So far, all I can find that is similar is the _cplusplus macro which, it
seems to me, tells us that we are compiling a C++ program and not a C
program but noit necessarily an ANSI-compliant C++ program. I would like
something that tells me the level of compliance so I can know whether or
not I have to enum or typedef a BOOL type and other things when I use
legacy code. Something like this:

#ifdef _ANSI_CPLUS_PLUS_
   typedef bool BOOL;  // we have the bool type
  // other defs that are ANSI-equivalent
#else
   enum BOOL { FALSE=0, TRUE=!FALSE}; // no bool type
   enum bool {false=0, true=!false};
   // other non-ANSI stuff
#endif

Thanks for the help,
Mark
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]





Author: jbuck@Synopsys.COM (Joe Buck)
Date: 1995/11/28
Raw View
krishtere@aol.com (Krishtere) writes:
>In the ANSI C std there is a macro something like _STD_C_ which could be
>used to determine if the compiler was ANSI-compliant:

Actually __STDC__ .  But if the draft standard were a standard, and if
such a macro existed for C++ it would always be defined to be false,
though.

>So far, all I can find that is similar is the _cplusplus macro which, it
>seems to me, tells us that we are compiling a C++ program and not a C
>program but noit necessarily an ANSI-compliant C++ program. I would like
>something that tells me the level of compliance so I can know whether or
>not I have to enum or typedef a BOOL type and other things when I use
>legacy code. Something like this:
>
>#ifdef _ANSI_CPLUS_PLUS_
>   typedef bool BOOL;  // we have the bool type
>  // other defs that are ANSI-equivalent
>#else
>   enum BOOL { FALSE=0, TRUE=!FALSE}; // no bool type
>   enum bool {false=0, true=!false};
>   // other non-ANSI stuff
>#endif

In real life, though, you'll find that all existing compilers have some
but not all features from the draft standard.  A compiler may have the
bool type but not have dynamic_cast, for example.  For the next several
years, we're probably going to have to have things like

#ifdef HAS_BOOL

etc.
--
-- Joe Buck  <jbuck@synopsys.com> (not speaking for Synopsys, Inc)
Anagrams for "information superhighway": Enormous hairy pig with fan
      A rough whimper of insanity
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]