错误:在C中'*'标记之前预期'=',',',';','asm'或'__attribute__' [英] error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token in C
问题描述
我有以下声明:
FILE * fptr;
FILE * optr;
in algo.h
我在main.c中打开了这些文件。
我得到上述错误,如果我把声明在头文件。如果我把它放在main.c中,那么我得到多个定义错误,比如:
$ b $ p $ b $ s $ s $ s $ s $ s $ .c :( .bss + 0xc88):多重定义 rcount'
condi'
src\\\
ew_algo.o:new_algo.c :( .bss + 0xc88):首先在这里定义
src\main.o:main.c :( .bss + 0xc8c):多重定义
src\\\
ew_algo.o:new_algo.c :( .bss + 0xc8c ):首先在这里定义
不是一个声明。如果你有 FILE * fptr; FILE * optr; 在源代码和头文件中,然后声明变量两次。
您需要:
algo.h
extern FILE * fptr;
extern FILE * optr;
algo.c
FILE * fptr;
FILE * optr;
I have the following declarations
FILE *fptr;
FILE *optr;
in algo.h I have the main in main.c which opens these files. I get the above error if I put the declarations in the header file. If I put it in the main.c, then I get mutiple definition errors like
src\main.o:main.c:(.bss+0xc88): multiple definition of
rcount'
src\new_algo.o:new_algo.c:(.bss+0xc88): first defined here
src\main.o:main.c:(.bss+0xc8c): multiple definition of
condi'
src\new_algo.o:new_algo.c:(.bss+0xc8c): first defined here
What you have in algo.h is a definition not a declaration. If you have FILE *fptr; FILE *optr; in both the source and the header file then you are declaring the variables twice.
You need:
algo.h
extern FILE *fptr;
extern FILE *optr;
algo.c
FILE *fptr;
FILE *optr;
这篇关于错误:在C中'*'标记之前预期'=',',',';','asm'或'__attribute__'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!