- 論壇徽章:
- 0
|
我在兩個文件里分別定義了名稱相同的兩種結(jié)構(gòu)體,但是它可以運行正常,不知道為啥,但同一文件里定義就不行,難道鏈接的時候不管嗎?,thanks
gcc test.c test2.c
test.c
- #include <stdio.h>
- #include <string.h>
- #include <string.h>
- typedef struct tstnode
- {
- int rightid;
- } TSTNODE;
- void test(void);
- int main(void) {
- test();
- test2();
- }
- void test(void) {
- TSTNODE a={1};
- printf("rightid is %d\n",a.rightid);
- }
復制代碼
test2.c
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct tstnode
- {
- char *leftid;
- } TSTNODE;
- void test2(void) {
- TSTNODE a={"abc"};
- printf("leftid is %s\n",a.leftid);
- }
復制代碼
[ 本帖最后由 wwdwwd 于 2009-11-21 13:57 編輯 ] |
|