Please Help Me Define and Macro Not Check Value

#include <Windows.h>
#include <iostream>

using namespace std;

#define MAX(a,b) (((a)>(b))?(a):(b))

int main()
{

int a = 7;
int b = 5;

cout << "Max : " << MAX(a, b) << endl;


/// Why This Not Working ! By a , b
#if MAX(a, b) == 7 // This Return Value 7 But Not Chechking...
cout << "a > b" << endl;
#else
cout << "a < b" << endl;
#endif

/// This Working ! By Put Num
#if MAX(7, 5) == 7
cout << "a > b" << endl;
#else
cout << "a < b" << endl;
#endif

system("pause");

return 0;
}

The #if directive is handled at compile time, so it must be possible to evaluate it at compile time. Since a and b are variables that can change at run time, MAX(a,b) can't be evaluated at compile time. In contrast, MAX(7,5) can.
ok thx but how can make macro same _MSC_VER return integer and can check int value
for exp :
MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
MSVC++ 7.1 _MSC_VER == 1310 (Visual Studio 2003)
MSVC++ 7.0 _MSC_VER == 1300
MSVC++ 6.0 _MSC_VER == 1200
MSVC++ 5.0 _MSC_VER == 1100

i very need to put int in macro from int or other var and check if later same msc #if _MSC_VER ==


Topic archived. No new replies allowed.