我的第一个文件是
名称:1.c
 
#include "1.h"
int main()
{
    a++;
    ft.a++;
    return 0;}
第二个文件是
名称:2.cextern int a;
extern fuct ft;
void test(void *arg)
{
    a++;
    ft.a++;
}
第三个文件是
名称:1.h
int a;
typedef struct _fuct_{
    int a;
}fuct;
fuct ft;但是编译不成功报extern fuct ft;
的错误....大家给我看看!

解决方案 »

  1.   

    不行呀大哥,
    我一在2.c里#include "1.h"
    的话,就报struct ft is redefine in 1.obj
    的错误!
      

  2.   

    1.h 改为
    #ifndef _1_h
    #define _1_hextern int a;
    typedef struct _fuct_{
        int a;
    }fuct;
    extern fuct ft;#endif2.c改为
    #include "1.h"
    int a;
    fuct ft;
    void test(void *arg)
    {
        a++;
        ft.a++;
    }
      

  3.   

    最好将变量定义在一个.c中
    int a;
    fuct ft;而在.h中加上
    extern int a;
    extern fuct ft;
      

  4.   

    各位大哥,不行呀,
    名称:2.c
    #include "l.h"
    int a;
    fuct ft;
    void test(void *arg)
    {
        a++;
        ft.a++;
    }名称:1.h
    extern int a;
    typedef struct _fuct_{
        int a;
    }fuct;
    extern fuct ft;我对这样做,link报错,你们能不能也试一试呀???
      

  5.   

    1.h文件你拷贝错误,请仔细看一下我的1.h和你这个1.h有什么不同。我刚才用了4种c编译器编译连接了1.c 和 2.c,没有任何问题
      

  6.   

    你看这样行不?
    #include "1.h"
    int a;
    fuct ft;
    int main()
    {
        a++;
        ft.a++;
        return 0;}
    第二个文件是
    名称:2.c
    #include "1.h"
    extern int a;
    extern fuct ft;
    void test(void *arg)
    {
        a++;
        ft.a++;
    }
    第三个文件是
    名称:1.h
    #ifndef  STRUCT_FUNCT
    #define  STRUCT_FUNCT
    typedef struct _fuct_{
    int a;
    }fuct;
    #endif
    这是另外一个兄弟提供的,我只是试了一下,确实可以!
      

  7.   

    把在1.h中定义的fuct ft;
    放到1.c中在2.c中#include "1.h"