with #pragma pop_macro("int")
#include <iostream>
using namespace std;
#define int double
void main()
{
int iOne = 1;
cout << sizeof(iOne) << endl;
#pragma push_macro("int")
#undef int
int iTwo = 2;
cout << sizeof(iTwo) << endl;
#pragma pop_macro("int")
}
without #pragma pop_macro("int")
#include <iostream>
using namespace std;
#define int double
void main()
{
int iOne = 1;
cout << sizeof(iOne) << endl;
#pragma push_macro("int")
#undef int
int iTwo = 2;
cout << sizeof(iTwo) << endl;
//#pragma pop_macro("int")
}
I have just tried on vs2017, nothing different.both have no warnings/errors, work fine, and have the same output:
8
4
So, my question is:
- Why vs allows this behavior?
- Is it UB?