12

In Microsoft Visual C++, I can use the macros _MSC_VER for compiler identification and _MSC_FULL_VER for its version number to retrieve the data of the used compiler at runtime of my C program. But they don't seem to exist in legacy Microsoft C 5.10. Borland C++, CLANG, GCC, Turbo C/C++ and Watcom C++ have similar macro definitions. ( __BORLANDC__, __clang__, __GNUC__, __TURBOC__ and __WATCOMC__)

But I couldn't find a macro for the legacy Microsoft C 5.10 compiler. I also couldn't find any information about it in the following list: Pre-defined Compiler Macros Wiki

Is there a macro for this compiler that could be evaluated to obtain the name (identifcation) and version of the compiler at runtime of my program? Or is there maybe a C function that is shipped with the compiler and does the same thing?

2
  • 3
    What is the underlying reason why you need to know this? Commented Aug 9 at 3:46
  • 4
    MSC 5.10 produces smaller binaries than Open Watcom 1.9 and much smaller binaries than GCC, but it lacks modern library functions and the error messages and the inbuilt help are terrible. By detecting the compiler, you can have customized source code for all 3 compilers in certain places and use the strengths of all three compilers. This is especially helpful with error messages and help, which is much better in gcc. MSC 5.10 was also included with the release of MS-DOS 4.x, which was placed under the MIT license. Unfortunately they did not include MSC 6.x.
    – Coder
    Commented Aug 9 at 13:21

2 Answers 2

13

Simple answer: No

You might get away with maybe a unique combination of pre-defined macros (and an absence test of _MSC_VER to exclude later versions).

MSC 5.1 defines (note no leading underscores!)

  MSDOS    /* target OS */
  M_I86    /* target CPU */
  M_I86xM  /* where x can be S, C, M, L or H (memory model) */

and that's about it.

1
  • 1
    Thanks, I think a combination of some of the predefined macros you mentioned will do the job.
    – Coder
    Commented Aug 8 at 19:53
8

No.

  • _MSC_VER was introduced first with MSC 6.0 containing 600, while
  • _MSC_FULL_VER came with Visual Studio 6 SP5 (_MSC_VER 1200)

Testing for _MSC_VER for not defined might be the only way - of course that's true for every other compiler and MSC before 6.0 - in combination with tests for some other compilers macros as well.

I guess it all depends on what feature this test should enable/avoid.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .