C 错误:函数和存储大小的隐式声明未知,尽管函数和结构是包含的头文件的成员
C errors: implicit declaration of function and storage size isn't known, despite the function and struct being members of an included header file
我正在尝试制作一个测试程序,它只搜索其根文件夹中的任何文件:
#include <stdio.h>
#include <dir.h>
#include <dos.h>
struct ffblk ffblk;
int main(){
int result = findfirst("*.*", &ffblk,FA_ARCH);
return 0;
}
但是当代码编译时,ffblk
struct
声明 returns 错误:
storage size of ffblk isn't known
和 findfirst()
函数 returns:
warning: implicit declaration of function 'findfirst'[-Wimplicit-function-declaration]
as seen in this image,尽管 findfirst
和 ffblk
都是 dir.h
的成员,dir.h
已经包含在内。我正在使用 Visual Studio
并使用 GCC
进行编译。有人知道代码或头文件有什么问题吗?
你真的,真的不应该使用过时的 APIs 来自过时的 headers,比如 "dos.h",如果你能完全避免的话。诚实!
然而,如果你坚持...
正如 dbush 指出的那样,实际的(过时的!)API 是 _findfirst
(不是 findfirst
)。
有记载here
你会看到这个参数(再次 - OBSOLETE)API 是 struct _finddata_t *fileinfo
(不是 struct ffblk
).
更改您的代码,一切都应该编译并且运行。
更好,将您的 headers 更改为 "io.h" 和 "dir.h")- 原始代码应该可以编译并且 运行.
我正在尝试制作一个测试程序,它只搜索其根文件夹中的任何文件:
#include <stdio.h>
#include <dir.h>
#include <dos.h>
struct ffblk ffblk;
int main(){
int result = findfirst("*.*", &ffblk,FA_ARCH);
return 0;
}
但是当代码编译时,ffblk
struct
声明 returns 错误:
storage size of ffblk isn't known
和 findfirst()
函数 returns:
warning: implicit declaration of function 'findfirst'[-Wimplicit-function-declaration]
as seen in this image,尽管 findfirst
和 ffblk
都是 dir.h
的成员,dir.h
已经包含在内。我正在使用 Visual Studio
并使用 GCC
进行编译。有人知道代码或头文件有什么问题吗?
你真的,真的不应该使用过时的 APIs 来自过时的 headers,比如 "dos.h",如果你能完全避免的话。诚实!
然而,如果你坚持...
正如 dbush 指出的那样,实际的(过时的!)API 是
_findfirst
(不是findfirst
)。有记载here
你会看到这个参数(再次 - OBSOLETE)API 是
struct _finddata_t *fileinfo
(不是struct ffblk
).
更改您的代码,一切都应该编译并且运行。
更好,将您的 headers 更改为 "io.h" 和 "dir.h")- 原始代码应该可以编译并且 运行.