cht電腦資訊Language
adm Find login register

preprocessor

qrtt1
1 preprocessor
Promote 0 Bookmark 02008-03-05quote  

http://pastie.caboo.se/161768 

 

typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_COUNT, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
#define DATA_UNSET \
        data_type_t type; \
        buffer *key; \
        int is_index_key; /* 1 if key is a array index (autogenerated keys) */ \
        struct data_unset *(*copy)(const struct data_unset *src); \
        void (* free)(struct data_unset *p); \
        void (* reset)(struct data_unset *p); \
        int (*insert_dup)(struct data_unset *dst, struct data_unset *src); \
        void (*print)(const struct data_unset *p, int depth)

typedef struct data_unset {
        DATA_UNSET;
} data_unset;

 

==========================================================

看這個真頭大:P 還好gcc能幫忙

qrtt1@debian:~/test$ gcc -E orz.c
# 1 "orz.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "orz.c"
typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_COUNT, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
# 12 "orz.c"
typedef struct data_unset {
        data_type_t type; buffer *key; int is_index_key; struct data_unset *(*copy)(const struct data_unset *src); void (* free)(struct data_unset *p); void (* reset)(struct data_unset *p); int (*insert_dup)(struct data_unset *dst, struct data_unset *src); void (*print)(const struct data_unset *p, int depth);
} data_unset;
 

 

eliu
2
Promote 0 Bookmark 12008-03-05quote  

cht電腦資訊Language
adm Find login register
views:6492