![]() |
![]() |
|||||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
|||
Q: Determine the version of the C++ compilerAnswerUse the __BORLANDC__ define. The Borland compiler always provides this define to you. You can read the value with #if preprocessor conditionals. The value of __BORLANDC__ tells you which version of the compiler is compiling your code. The values are: 0x550 : C++Builder 5.0 or the free BC55 compiler 0x540 : C++Builder 4.0 0x530 : C++Builder 3.0 0x520 : C++Builder 1.0 and Borland C++ 5.02 0x4XX : Borland C++ 4.X. (I don't know the exact values)
Here is an example that shows how to use these values in a preprocessor conditional. #include <iostream> #pragma hdrstop using namespace std; int main() { cout << "__BORLANDC__ == 0x" << std::hex << __BORLANDC__ << endl; #if (__BORLANDC__ >= 0x560) cout << "It's a future version. Woohoo!" << endl; #elif (__BORLANDC__ >= 0x550) cout << "BCB5 detected." << endl; #elif (__BORLANDC__ >= 0x540) cout << "BCB4 detected." << endl; #elif (__BORLANDC__ >= 0x530) cout << "BCB3 detected." << endl; #else cout << "Very old version detected." << endl; #endif return 0; } | ||||||||
All rights reserved. |