C--宏定义

#include
#include
#include

#define Malloc(type,x) (type*)malloc(sizeof(type)*x)
#define FREE§ (free§,p=NULL)
#define LOG(s) printf("[%s] {%s:%d} %s",DATE,FILE,LINE,s)
#define FOREACH(i,m) for(i=0;i #define BEGIN {
#define END }

int main()
{
int x = 0;
int* p = Malloc(int,5);

FOREACH(x,5)
BEGIN
    p[x] = x;
END

FOREACH(x,5)
BEGIN
    printf("p[x] = %d.\n",p[x]);
END
LOG("hello");

FREE(p);
return 0;

}

你可能感兴趣的:(C)