I'm trying to make a test program that simply searches for any file in its root folder:
#include <stdio.h>
#include <dir.h>
#include <dos.h>
struct ffblk ffblk;
int main(){
int result = findfirst("*.*", &ffblk,FA_ARCH);
return 0;
}
But when the code compiles, the ffblk
struct
declaration returns the error:
storage size of ffblk isn't known
and the findfirst()
function returns:
warning: implicit declaration of function 'findfirst'[-Wimplicit-function-declaration]
as seen in this image, even though both findfirst
and ffblk
are members of dir.h
, which is already included. I'm using Visual Studio
and compiling with GCC
. Does someone know what is wrong with the code, or the header files?
You really, really shouldn't be using obsolete APIs from obsolete headers like "dos.h" if you can at all avoid it. Honest!
Nevertheless, if you insist...
As dbush pointed out, the actual (obsolete!) API is _findfirst
(not findfirst
).
It is documented here
You'll see that the argument for this (again - OBSOLETE) API is struct _finddata_t *fileinfo
(not struct ffblk
).
Change your code, and everything should compile and run.
Better, change your headers (to "io.h" and "dir.h") - and the original code should probably compile and run.