c++的#和##的用法
作者:互联网
#include <iostream>
using namespace std;
#define WARN_IF(EXP) if(EXP) cerr << #EXP << endl;
#define paster( n ) cout << "token" << #n << " = " << n << endl;
#define _CONS(a, b) int(a##+##b)
#define _STRI(s) #s
#define STRI(s) _STRI(s)
void main()
{
int div = 0;
WARN_IF(div == 0); // prints : div == 0
paster(9); // prints : token9 = 9
cout << _CONS(1, 2) << endl; // prints : 3
cout << _STRI(INT_MAX) << endl; // prints : INT_MAX
cout << STRI(INT_MAX) << endl; // prints : 2147483647
}
标签:prints,cout,##,c++,用法,STRI,EXP,div,define 来源: https://www.cnblogs.com/xiaochouk/p/15913144.html