Pelles C forum

C language => Beginner questions => Topic started by: rp108 on August 18, 2014, 03:31:26 AM

Title: Structure define not recognized by compiler
Post by: rp108 on August 18, 2014, 03:31:26 AM
I am using the microsoft _findfirst, _findnext, etc functions to scan a directory for files.

These functions require the  io.h  file to be included.

In the io.h file, there is a structure defined that holds the data that is found:
struct _finddata_t {
    unsigned int attrib;
    time_t time_create;
    time_t time_access;
    time_t time_write;
    unsigned long size;
    char name[260];
};

I have written a scanning function to call  _findfirst and  _findnext.
My scanning function declares a variable finfo:

_finddata_t finfo;

I have included  io.h  before the scanning function occurs in the  main.c file, but the Pelles C compiler complains (about the above code line):

error #2048: Undeclared identifier '_finddata_t'.

As an experiment, I defined the structure (exactly as above) within my scanning function itself, but I still get the very same error.

I actually copied code I had written years ago in VisStudio, and it worked there.....

Any help is much appreciated.

Thanks,
Robert



Title: Re: Structure define not recognized by compiler
Post by: JohnF on August 18, 2014, 07:00:16 AM
Try

struct _finddata_t finfo;

John
Title: Re: Structure define not recognized by compiler
Post by: frankie on August 18, 2014, 10:30:16 AM
As John said you must use:
struct _finddata_t finfo;
the reason is that there is no 'typedef' for '_finddata_t'.
Title: Re: Structure define not recognized by compiler
Post by: rp108 on August 19, 2014, 02:57:32 AM


Thank-you gentlemen  !!