cht電腦資訊Language
adm Find login register

preprocessor

qrtt1

joined: 2007-10-02
posted: 82
promoted: 18
bookmarked: 5
藍星
1subject: preprocessorPromote 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

joined: 2007-08-09
posted: 11480
promoted: 617
bookmarked: 187
新竹, 台灣
2subject: Promote 0 Bookmark 12008-03-05quote  

我以前也是用 -E 來看,可以寫個 rule 放到 Makefile

 

 .c.E:
    $(CC) $(CFLAGS) -E -o $@ $<

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