Pelles C forum

Pelles C => Bug reports => Topic started by: frankie on November 05, 2012, 11:00:25 AM

Title: Erratic definition of getwdelim & getwline
Post by: frankie on November 05, 2012, 11:00:25 AM
The definition of these two functions miss the 'struct' specifier before FILE type.
Actually they are defined as:
Code: [Select]
extern ssize_t __cdecl getwdelim(wchar_t ** restrict, size_t * restrict, wint_t, FILE *);
extern ssize_t __cdecl getwline(wchar_t **, size_t *, FILE *);
The correct declaration is:
Code: [Select]
extern ssize_t __cdecl getwdelim(wchar_t ** restrict, size_t * restrict, wint_t, struct FILE *);
extern ssize_t __cdecl getwline(wchar_t **, size_t *, struct FILE *);

P.S. For those who don't have much confidence these functions are defined in <wchar.h> header and are part of extended library for dynamic allocation functions (TR24731-2) which can be made available defining the symbol '__STDC_WANT_LIB_EXT2__' at beginning of your source file.
In wchar.h FILE is redefined as an incomplete structure
Code: [Select]
  struct FILE;
So referencing to the typedef FILE is no more valid (you *must* reference it as 'struct FILE').
Title: Re: Erratic definition of getwdelim & getwline
Post by: CommonTater on November 05, 2012, 11:30:23 AM
Hi Frankie ...
 
FILE is typedefed in stdio.h so those definitions should be ok...
 
Code: [Select]
#ifndef _WINCE
typedef struct FILE {
#if __POCC__ >= 500
    unsigned int mode;
#else
    unsigned short mode;
    unsigned short pad;
#endif /* __POCC__ */
    int fh;
    unsigned char *buf, *bufend, *ptr;
    unsigned char *getend, *putend, *backptr;
    wchar_t *wbackptr, wbackbuf[2];
    unsigned char *getback, *wgetend, *wputend;
    mbstate_t wstate;
    char *tmpnam;
    unsigned char backbuf[8], cbuf;
#if __POCC__ >= 500
    int locknum;
#endif /* __POCC__ >= 500 */
} FILE;

 
Title: Re: Erratic definition of getwdelim & getwline
Post by: frankie on November 05, 2012, 01:47:13 PM
Tater,
I remember to have heard about that!   ::)

Try to include to define __STDC_WANT_LIB_EXT2__ 1 and then include  <wchar.h> ........
Title: Re: Erratic definition of getwdelim & getwline
Post by: TimoVJL on November 05, 2012, 02:25:02 PM
Or typedef struct FILE FILE; ?
Code: [Select]
#define __STDC_WANT_LIB_EXT2__ 1
//#include <wchar.h>
#ifndef _WCHAR_H
typedef unsigned int size_t;
typedef long ssize_t;
typedef unsigned short wchar_t;
typedef unsigned short wint_t;
typedef struct FILE FILE;
#endif
extern ssize_t __cdecl getwdelim(wchar_t ** restrict, size_t * restrict, wint_t, FILE *);
extern ssize_t __cdecl getwline(wchar_t **, size_t *, FILE *);
int main(int argc, char **argv)
{
return 0;
}
Title: Re: Erratic definition of getwdelim & getwline
Post by: frankie on November 05, 2012, 02:31:02 PM
Timo,
your workaround is godd as usual  ;)
Anyway it is simply a typo error in the header file.
Pelle should correct it in the next release.