C++ compiler version in runtime

SurgicalShark

Golden Member
Mar 30, 2004
1,275
0
76
Hi, I am interested in knowing compiler version before compile the program, how can I do that?

For example, I have both VC6 (Visual Studio 6) and VC8/? (Visual Studion 2005), now some of the functions are deprecated in latest version of VS, such as "fopen." VS 2005 asks me to use fopen_s instead of fopen.

To resolve this problem, I can make some changes in the code, so that it will run on both version without any warnings or errors.

So how can I determine compiler version of C++?

Thanks,
Neil.
 

SurgicalShark

Golden Member
Mar 30, 2004
1,275
0
76
HI Chad,
Thanks for your message, I have my code running with #ifdef..#else..#endif directive, so at the start of compilation on VC 6 machine I need to delete the macro which directs compiler to VC 8 code.

But I am more interested in automating this process, so in that instace I even don't need to add/delete the macro. Do you know any such thing?

Neil.
 

itachi

Senior member
Aug 17, 2004
390
0
0
that's bullsht.. microsoft took the liberty to deprecate functions that aren't really deprecated by ansi standards. just define the macro _CRT_SECURE_NO_DEPRECATE.

#ifdef _MSC_VER
# if _MSC_VER >= 1400 // VC8.0 or greater
# define _CRT_SECURE_NO_DEPRECATE
# endif
#endif
 

SurgicalShark

Golden Member
Mar 30, 2004
1,275
0
76
That's exactly what I was looking for. Thanks!

I hear ya about M$ and VS 2005....sometimes it just gets on my nerves.