A
Achraf Belkahla
Guest
I am trying to migrate a project from Borland C++ to Visual C++
I noticed a difference in treating enum as explained by this example
File : Test_enum.cpp
#ifdef _MSC_VER
#include <iostream>
#else
#include <iostream.h>
#endif
#include <conio.h>
using namespace std;
enum {
ENUM_0 =0,
ENUM_1,
ENUM_2,
ENUM_3
} ;
int main(int argc, char* argv[])
{
#ifdef _MSC_VER
cout << "Microsoft Visual compiler detected!" << endl;
#elif defined(__BORLANDC__)
cout << "Borland compiler detected!" << endl;
#elif
cout << "Other compiler detected!" << endl;
#endif
#if ENUM_1 > 0
cout << "ENUM_1 is well defined at preprocessing time" << endl;
#else
cout << "No way to see enum variables at preprocessing time" << endl;
#endif
cout << "Type any character to exit..." << endl;
#ifdef _MSC_VER
_getch();
#else
getch();
#endif
return 0;
}
Runing the code in visual studio gives this output :
Microsoft Visual compiler detected!
No way to see enum variables at preprocessing time
Type any character to exit...
And by using Borland, i get :
Borland Compiler detected!
ENUM_1 is well defined at preprocessing time
Type any character to exit...
I want to know how Borland is able to recognize the enum ? Is it possible to do the same in visual?
Continue reading...
I noticed a difference in treating enum as explained by this example
File : Test_enum.cpp
#ifdef _MSC_VER
#include <iostream>
#else
#include <iostream.h>
#endif
#include <conio.h>
using namespace std;
enum {
ENUM_0 =0,
ENUM_1,
ENUM_2,
ENUM_3
} ;
int main(int argc, char* argv[])
{
#ifdef _MSC_VER
cout << "Microsoft Visual compiler detected!" << endl;
#elif defined(__BORLANDC__)
cout << "Borland compiler detected!" << endl;
#elif
cout << "Other compiler detected!" << endl;
#endif
#if ENUM_1 > 0
cout << "ENUM_1 is well defined at preprocessing time" << endl;
#else
cout << "No way to see enum variables at preprocessing time" << endl;
#endif
cout << "Type any character to exit..." << endl;
#ifdef _MSC_VER
_getch();
#else
getch();
#endif
return 0;
}
Runing the code in visual studio gives this output :
Microsoft Visual compiler detected!
No way to see enum variables at preprocessing time
Type any character to exit...
And by using Borland, i get :
Borland Compiler detected!
ENUM_1 is well defined at preprocessing time
Type any character to exit...
I want to know how Borland is able to recognize the enum ? Is it possible to do the same in visual?
Continue reading...