#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//# ##
//# 如果写在宏函数体的内部, # 表示生成一个字符串。
#define STR(s) \
#s
//## 如果卸载宏函数体的内部, ## 表示拼接两个C token
#define A(first, second) first##second
#define G(a) g_##a
#define ITCAST(a) itcast_##a
#define SHOW_LIST(...) \
printf(#__VA_ARGS__)
#define compare(test, ...) \
(test) ? (#test) : printf(#__VA_ARGS__);
int main(int argc, char **argv)
{
printf(STR(main(10,20,30)));
printf("\n");
A(printf, ("%s\n", "abc"););
printf("%s\n", "abc");
int G(value) = 10; // int g_value = 10;
int ITCAST(value2) = 20;// int itcast_value2 = 20;
printf("000000\n");
SHOW_LIST(dsadsasa, 321321, dsadas, 32132);
printf("\n");
int aa = 10;
int bb = 20;
compare((aa > bb), a is little than b);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define DEBUG(format, ...) \
do { \
printf("[DEBUG][%s:%d][%s:%s]"format, __FUNCTION__, __LINE__, __DATE__, __TIME__, ##__VA_ARGS__); \
} while (0)
#define ERROR(format, ...) \
do { \
printf("[ERROR][%s:%d][%s:%s]"format, __FUNCTION__, __LINE__, __DATE__, __TIME__, ##__VA_ARGS__); \
} while (0)
int main(int argc, char **argv)
{
char *p = NULL;
p = (char*)malloc(100);
if (p == NULL) {
ERROR("p==NULL\n"); //error p == NULL
//printf("error, p == NULL \n");
return -1;
}
int a = 10;
DEBUG("p malloc succ %d, %d\n", a, a); //debug, p malloc succ!
//printf("debug, p malloc succ!\n");
return 0;
}