telling the version of CW

telling the version of CW

Post by Denis Pel » Fri, 24 Mar 1995 11:56:30



I asked Metrowerks how a C program can determine what version of the
compiler is used. [This is useful for version-dependent work-arounds, and
for keeping track of what compiler version was used to generate an
important program and any data it produces.] I was told that there's no
way to tell. So I wrote my own code, see below. It successfully
distinguishes the major versions (CW4, 5, and the future 6, assuming they
fix the fourbyteints bug), and detects version 5.5 of the 68k compiler.
Does anyone know a way to distinguish versions 5 and 5.5 of the ppc
compiler?

#define __CW__ 4
#if defined(__fourbyteints__) // this symbol first appeared in version CW5
   #undef __CW__
   #define __CW__ 5
   #if !defined(powerc)
      #if __option(IEEEdoubles) == __ieeedoubles__  // false in CW5 68k
         #undef __CW__
         #define __CW__ 5.5
      #endif
      #pragma fourbyteints off
      #if __option(fourbyteints) == __fourbyteints__ // false in CW5 & 5.5 68k
         #undef __CW__
         #define __CW__ 6
      #endif
      #pragma fourbyteints reset
   #else
      // I don't know how to distinguish version 5.5 from 5 of the ppc compiler.
   #endif
#endif

To test this code, follow it by
__CW__
and preprocess it without any precompiled header. I've tested in on CW 5
and 5.5, both 68k and ppc.

Denis Pelli
Professor of Neuroscience
Syracuse University

 
 
 

telling the version of CW

Post by Denis Pel » Sat, 25 Mar 1995 02:12:55


Quote:> I've tested it on CW 5 and 5.5, both 68k and ppc [versions of the compiler].

P.S. Oops. I should have mentioned that I did all the testing on a Power
Mac (6100/66, System 7.1). I just discovered, to my surprise, that the
CW5.5 68k compiler's fourbyteints-preprocessor-option bug that my code
exploits doesn't occur when you run the same compiler on a 68k Mac
(PowerBook 170, System 7.1).

--
Denis Pelli
Professor of Neuroscience
Syracuse University