www.digitalmars.com         C & C++   DMDScript  

c++ - Major/minor

reply "Matthew Wilson" <dmd synesis.com.au> writes:
Walter

Is there any chance of your adding the following pre-processor symbols to
the compiler:

__DMC_MAJOR__ == e.g. 8
__DMC_MINOR__ == e.g. 32
__DMC_REVISION__ == e.g. 0 for a release, or 1,2 etc. for the beta

(both the numbers being decimal), or

__DMC_VERSION_STRING__ == e.g. "8.32b"

Basically, I'm racking the brain to think of a way to extract and stringise
the required information from __DMC__, and am coming up empty. Obviously
things such as the following do NOT give the desired result

#define __stringize_ccver(x) #x
#define _stringize_ccver(x)  __stringize_ccver(x)
#define _dmc_major    _stringize_ccver(__DMC__ & 0xf00)
#define _dmc_minor    _stringize_ccver(__DMC__ & 0xff)

#pragma message("Digital Mars C/C++: " _dmc_major " " _dmc_minor)


The reason I ask is that it'd be great if I could constrain the expansion of
the DMC section in the STLSoft root header (stlsoft.h) to the following:


#elif defined(__DMC__)
/* Digital Mars C/C++ */
 #define _STLSOFT_COMPILER_IS_DMC

 #if (__DMC__ < 0x0826)
  #error Only versions 8.26 and later of the Digital Mars C/C++ compilers
are supported by the STLSoft libraries
 #elif (__DMC__ >= 0x0832)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ " __DMC_VERSION_STRING__)   <<==
WALTER: This would be the cool stuff. :)
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #elif (__DMC__ == 0x0826)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ 8.26")
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #elif (__DMC__ == 0x0827)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ 8.27")
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #elif (__DMC__ == 0x0828)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ 8.28")
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #elif (__DMC__ == 0x0829)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ 8.29")
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #elif (__DMC__ == 0x0830)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ 8.30")
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #elif (__DMC__ == 0x0831)
  #ifdef _STLSOFT_COMPILE_VERBOSE
   #pragma message("Digital Mars C/C++ 8.31")
  #endif /* _STLSOFT_COMPILE_VERBOSE */
 #endif /* __DMC__ */


which would allow me to end the repetition - which is a function of the
in-all-other-respects excellent policy that you have of updating your
compiler in a reasonable timeframe - at 8.32, otherwise it's going to get
real ugly.

I realise it seems a pretty partial request, but hey, I thought I'd give it
a shot!

Matthew
Nov 28 2002
parent reply "Walter" <walter digitalmars.com> writes:
I guess I don't know why it matters. It should, of course, check to see that
the version is >= some minimum version, and leave it at that. Why print out
which version when compiling?

"Matthew Wilson" <dmd synesis.com.au> wrote in message
news:as67ol$sve$1 digitaldaemon.com...
 Walter

 Is there any chance of your adding the following pre-processor symbols to
 the compiler:

 __DMC_MAJOR__ == e.g. 8
 __DMC_MINOR__ == e.g. 32
 __DMC_REVISION__ == e.g. 0 for a release, or 1,2 etc. for the beta

 (both the numbers being decimal), or

 __DMC_VERSION_STRING__ == e.g. "8.32b"

 Basically, I'm racking the brain to think of a way to extract and
stringise
 the required information from __DMC__, and am coming up empty. Obviously
 things such as the following do NOT give the desired result

 #define __stringize_ccver(x) #x
 #define _stringize_ccver(x)  __stringize_ccver(x)
 #define _dmc_major    _stringize_ccver(__DMC__ & 0xf00)
 #define _dmc_minor    _stringize_ccver(__DMC__ & 0xff)

 #pragma message("Digital Mars C/C++: " _dmc_major " " _dmc_minor)


 The reason I ask is that it'd be great if I could constrain the expansion
of
 the DMC section in the STLSoft root header (stlsoft.h) to the following:


 #elif defined(__DMC__)
 /* Digital Mars C/C++ */
  #define _STLSOFT_COMPILER_IS_DMC

  #if (__DMC__ < 0x0826)
   #error Only versions 8.26 and later of the Digital Mars C/C++ compilers
 are supported by the STLSoft libraries
  #elif (__DMC__ >= 0x0832)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ " __DMC_VERSION_STRING__)   <<==
 WALTER: This would be the cool stuff. :)
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0826)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.26")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0827)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.27")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0828)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.28")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0829)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.29")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0830)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.30")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0831)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.31")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #endif /* __DMC__ */


 which would allow me to end the repetition - which is a function of the
 in-all-other-respects excellent policy that you have of updating your
 compiler in a reasonable timeframe - at 8.32, otherwise it's going to get
 real ugly.

 I realise it seems a pretty partial request, but hey, I thought I'd give
it
 a shot!

 Matthew
Nov 28 2002
parent "Matthew Wilson" <dmd synesis.com.au> writes:
It's just something I've tended to do over the years, mainly for my own
purposed, but has been surprisingly popular with my clients, as it can be a
simple eye-catcher in build logs.

As I said, it's no biggie, but would be useful if it cost you minimal
effort. If I had my choice, I would prefer something similar to the GCC way
of doing it, i.e. __DMC_MAJOR__ and __DMC_MINOR__. These then make it much
easier to write version-discrimination code, and they can be individually
stringised when that is required. I probably emphasised the stringising
aspect to the requirement more than I should, as the version-discrimination
is more valuable.

No biggie, anyway. I realise you have _much_ more important things on your
plate.

Matthew

"Walter" <walter digitalmars.com> wrote in message
news:as75ti$23a9$1 digitaldaemon.com...
 I guess I don't know why it matters. It should, of course, check to see
that
 the version is >= some minimum version, and leave it at that. Why print
out
 which version when compiling?

 "Matthew Wilson" <dmd synesis.com.au> wrote in message
 news:as67ol$sve$1 digitaldaemon.com...
 Walter

 Is there any chance of your adding the following pre-processor symbols
to
 the compiler:

 __DMC_MAJOR__ == e.g. 8
 __DMC_MINOR__ == e.g. 32
 __DMC_REVISION__ == e.g. 0 for a release, or 1,2 etc. for the beta

 (both the numbers being decimal), or

 __DMC_VERSION_STRING__ == e.g. "8.32b"

 Basically, I'm racking the brain to think of a way to extract and
stringise
 the required information from __DMC__, and am coming up empty. Obviously
 things such as the following do NOT give the desired result

 #define __stringize_ccver(x) #x
 #define _stringize_ccver(x)  __stringize_ccver(x)
 #define _dmc_major    _stringize_ccver(__DMC__ & 0xf00)
 #define _dmc_minor    _stringize_ccver(__DMC__ & 0xff)

 #pragma message("Digital Mars C/C++: " _dmc_major " " _dmc_minor)


 The reason I ask is that it'd be great if I could constrain the
expansion
 of
 the DMC section in the STLSoft root header (stlsoft.h) to the following:


 #elif defined(__DMC__)
 /* Digital Mars C/C++ */
  #define _STLSOFT_COMPILER_IS_DMC

  #if (__DMC__ < 0x0826)
   #error Only versions 8.26 and later of the Digital Mars C/C++
compilers
 are supported by the STLSoft libraries
  #elif (__DMC__ >= 0x0832)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ " __DMC_VERSION_STRING__)   <<==
 WALTER: This would be the cool stuff. :)
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0826)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.26")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0827)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.27")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0828)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.28")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0829)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.29")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0830)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.30")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #elif (__DMC__ == 0x0831)
   #ifdef _STLSOFT_COMPILE_VERBOSE
    #pragma message("Digital Mars C/C++ 8.31")
   #endif /* _STLSOFT_COMPILE_VERBOSE */
  #endif /* __DMC__ */


 which would allow me to end the repetition - which is a function of the
 in-all-other-respects excellent policy that you have of updating your
 compiler in a reasonable timeframe - at 8.32, otherwise it's going to
get
 real ugly.

 I realise it seems a pretty partial request, but hey, I thought I'd give
it
 a shot!

 Matthew
Nov 29 2002