stolencoin
February 2nd, 2010, 05:20 PM
Hi
The documentation says that #pragma comment (compiler)places the name and version number of the compiler in object file. Is there a way to retrieve this information programmatically from my own program?
ovidiucucu
February 3rd, 2010, 04:15 AM
As stated in MSDN, #pragma comment(compiler) places the name and version number of the compiler in the object file (.obj). Further, this comment record is ignored by the linker.
So, it cannot be found in the exe/dll file, then it's not possible to retrieve it at run-time.
Alternatively, you can use _MSC_VER predefined macro to get the compiler version. For example, in the compiler from Visual C++ 6.0 _MSC_VER has a value of 1200, while in Visual C++ 2005, _MSC_VER is 1400.
Fore more info see:
[MSDN] #pragma comment (http://msdn.microsoft.com/en-us/library/7f0aews7(VS.80).aspx)
[MSDN] Predefined Macros (http://msdn.microsoft.com/en-us/library/b0084kay(VS.80).aspx)
stolencoin
February 5th, 2010, 09:37 AM
Thanks ovidiucucu (could not login for two days!). _MSC_VER is the way to go. Not really important but what's the point of this pragma compiler directive anyway...