So, the VC++ compiler version of my system is 15.00.21022.08. In this period delimited version number, the major number corresponds to the first component , 15 and the minor number corresponds to the second component, 00. So for Visual studio 2008, the _MSC_VER macro evaluates to 1500.
Example1:
// is executed. Else this portion of code will be inactive.
int main(int argc, char* argv[])
{
//some come
return 0;
}
#else
//if it is any other compiler other than MicroSoft, the below main()
//function is executed. Else this portion of code will be inactive.
int main(int argc, char* argv[])
{
//some come
return 0;
}
#endif
In the above code snippet, it is shown that it has two ‘main()’ functions. But out of these two, at any point, only one will be active and the other is totally inactive. The compiler only identifies the main() function relevant to it. There by this does not result in any compiler error.
Example2:
#if (_MSC_VER >= 1400)
//VC 8.0: Executes this part of the code if the Compiler is VC 8.0
// and above.
#elseif (_MSC_VER >= 1310)
// VC 7.1: Executes this part of the code if the Compiler is VC 7.1.
#elseif (_MSC_VER >= 1300)
// VC 7.0: Executes this part of the code if the Compiler is VC 7.0.
#else
// VC 6.0: Executes this part of the code if the Compiler is VC 6.0.
#endif
In the above example a distinction is made between the various versions of Microsoft compiler. So based on the compiler version that part of the code executes and not all.
No comments:
Post a Comment