我的第一个文件是
名称: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.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;
的错误....大家给我看看!
我一在2.c里#include "1.h"
的话,就报struct ft is redefine in 1.obj
的错误!
#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++;
}
int a;
fuct ft;而在.h中加上
extern int a;
extern fuct ft;
名称: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报错,你们能不能也试一试呀???
#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
这是另外一个兄弟提供的,我只是试了一下,确实可以!
放到1.c中在2.c中#include "1.h"