NO

Author Topic: Erratic definition of getwdelim & getwline  (Read 3302 times)

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Erratic definition of getwdelim & getwline
« 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').
« Last Edit: November 05, 2012, 02:01:18 PM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

CommonTater

  • Guest
Re: Erratic definition of getwdelim & getwline
« Reply #1 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;

 
« Last Edit: November 05, 2012, 11:32:05 AM by CommonTater »

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Erratic definition of getwdelim & getwline
« Reply #2 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> ........
« Last Edit: November 05, 2012, 01:59:46 PM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Erratic definition of getwdelim & getwline
« Reply #3 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;
}
May the source be with you

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Erratic definition of getwdelim & getwline
« Reply #4 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.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide