#include
#include
#include
using namespace std;
#define Conn(x,y) x##y
#define tochar(x) #@x
#define tostring(x) #x
#define MEM_B(x)(*((byte*)(x)))
#define MEM_W(x)(*((WORD*)(x)))
#define OFFSETOF(type,field) ((size_t)& ((type*)0)->field)
#define FSIZ(type,field) sizeof( ((type *) 0)->field )
#define B_PTR( var ) ( (byte *) (void *) &(var) )
#define W_PTR( var ) ( (WORD *) (void *) &(var) )
#define UPCASE( c ) ( ((c) >= 'a' && (c) <= 'z') ? ((c) - 0x20) : (c) )
#define INC_SAT( val ) (val = ((val)+1 > (val)) ? (val)+1 : (val))
#define ARR_SIZE( a ) ( sizeof( (a) ) / sizeof( (a[0]) ) )
#define _LINE_ __LINE__
struct Person
{
string name;
int age;
};
void test01()
{
cout << Conn(123, 444) << endl;
cout << Conn("abc", "efg") << endl;
auto a2 = tochar(4);
cout << a2 << endl;
cout << typeid(a2).name() << endl;
auto a3 = tostring(43434);
cout << a3 << endl;
cout << typeid(a3).name() << endl;
int bTest = 0x123456;
byte m = MEM_B((&bTest));
cout << int(m) << endl;
int n = MEM_W((&bTest));
cout << int(n) << endl;
struct Person p = { "dsd",88 };
cout << OFFSETOF(Person, name) << endl;
cout << OFFSETOF(Person, age) << endl;
cout << FSIZ(Person, age) << endl;
cout << FSIZ(Person, name) << endl;
int num = 97;
cout << B_PTR(num) << endl;
cout << W_PTR(num) << endl;
cout << UPCASE('a') << endl;
int num1 = 99;
int num2 = 99999999999999999;
cout << INC_SAT(num1) << endl;
cout << INC_SAT(num2) << endl;
int arr[] = { 1,2,43,5 };
int arr1[][4] =
{
{1, 2, 3, 5},
{ 1,2,3,5 },
};
cout << ARR_SIZE(arr) << endl;
cout << ARR_SIZE(arr1) << endl;
int x = 0;
int y = 10;
if (y > x) {
printf("Error: y is greater than x at line %d\n", _LINE_);
}
}
int main()
{
test01();
system("pause");
return 0;
}