NO

Author Topic: Structure define not recognized by compiler  (Read 2928 times)

rp108

  • Guest
Structure define not recognized by compiler
« 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




JohnF

  • Guest
Re: Structure define not recognized by compiler
« Reply #1 on: August 18, 2014, 07:00:16 AM »
Try

struct _finddata_t finfo;

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Structure define not recognized by compiler
« Reply #2 on: August 18, 2014, 10:30:16 AM »
As John said you must use:
Code: [Select]
struct _finddata_t finfo;the reason is that there is no 'typedef' for '_finddata_t'.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

rp108

  • Guest
Re: Structure define not recognized by compiler
« Reply #3 on: August 19, 2014, 02:57:32 AM »


Thank-you gentlemen  !!