[PATCH] Avoid more problems with type clashes

Corinna Vinschen vinschen@redhat.com
Thu Mar 13 09:11:00 GMT 2003

On Wed, Mar 12, 2003 at 07:08:49PM -0500, J. Johnston wrote:
> I hadn't forgotten.  I do not understand why you are
> avoiding the fpos_t type.  It is supposed to be defined by stdio.h.
> Could you provide a little more detail the actual problem you are seeing
> that this patch fixes?

fpos_t != _fpos_t.

_fpos_t as well as _fpos64_t are the definitions internally to newlib. 
So it should be used by internal functions to avoid type clashes with
the type fpos_t which could change.

See stdio.h:

  #ifdef __CYGWIN__
  typedef _fpos64_t fpos_t;
  typedef _fpos_t fpos_t;
  typedef _fpos_t fpos_t;
  #ifdef __LARGE64_FILES
  typedef _fpos64_t fpos64_t;
  #endif /* !__CYGWIN__ */

Cygwin up to the recent 1.3.21 doesn't define __CYGWIN_USE_BIG_TYPES__
so fpos_t == _fpos_t == 32bit.  The next version of Cygwin will define
__CYGWIN_USE_BIG_TYPES__ and then the types fpos_t and off_t are 64bit
types.  This shall work without any user intervention, no extra functions
for 64bit file access needed.

A newly compiled program will further use "fgetpos" but it will actually
call "fgetpos64" while applications built with Cygwin up to 1.3.21 will
still call the old entry points.  But since newlib itself uses fpos_t
internally so far, the 32bit entry points are either wrong compiled or
the compiler complains at compile time as soon as __CYGWIN_USE_BIG_TYPES__
is defined.


Corinna Vinschen
Cygwin Developer
Red Hat, Inc.

More information about the Newlib mailing list