Erratic definition of getwdelim & getwline

Started by frankie, November 05, 2012, 11:00:25 AM

Previous topic - Next topic

frankie

The definition of these two functions miss the 'struct' specifier before FILE type.
Actually they are defined as:
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:
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
  struct FILE;
So referencing to the typedef FILE is no more valid (you *must* reference it as 'struct FILE').
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

CommonTater

#1
Hi Frankie ...

FILE is typedefed in stdio.h so those definitions should be ok...

#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;



frankie

#2
Tater,
I remember to have heard about that!   ::)

Try to include to define __STDC_WANT_LIB_EXT2__ 1 and then include  <wchar.h> ........
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

TimoVJL

Or typedef struct FILE FILE; ?
#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;
}
May the source be with you

frankie

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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide