- 论坛徽章:
- 0
|
- #include <stdio.h>
- #define BUFPOINT(flag,ptr) ((flag)?(MYSTRUCT_ONE *)(ptr):(MYSTRUCT_TWO *)(ptr))
- typedef struct _MYSTRUCT_ONE
- {
- int mm;
- char nn;
- } MYSTRUCT_ONE;
- typedef struct _MYSTRUCT_TWO
- {
- int mm;
- char nn;
- long zz;
- } MYSTRUCT_TWO;
-
- int main(int argc,char *argv[])
- {
- int flag;
- MYSTRUCT_ONE one = {9,'1'};
- MYSTRUCT_TWO two = {8,'2',777};
- void *ps = NULL;
- if(argc < 2)
- {
- ps = &one;
- flag = 1;
- }
- else
- {
- ps = &two;
- flag = 0;
- }
- printf("ps->mm[%d]\n",BUFPOINT(flag,ps)->mm); //这里编译不过
- return 0;
- }
复制代码 我知道模版可以,我想知道c编译器该怎么做? |
|