This is the mail archive of the
mailing list for the Cygwin project.
Re: Problem in calling _stat() on Cygwin 1.7
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: cygwin at cygwin dot com
- Date: Sat, 27 Feb 2010 17:53:52 +0000
- Subject: Re: Problem in calling _stat() on Cygwin 1.7
- References: <email@example.com>
On 27/02/2010 15:14, Dave Lee wrote:
>> If it (meddling with internal affairs, such as using _stat) hurts too
>> much, then don't do it (use stat instead, it's standardized).
> An off-topic question: on system where both XXX() and _XXX() are available
> (where XXX = open, read, write, access, chmod, ... etc), can one assume
> what _XXX() does, and that _XXX() behaves the same as XXX()?
Not in general, no. Anything beginning with an underscore is, as a general
rule, private and internal to the library or toolchain. Or, as is probably
the case in the code this originally came from, it's a reference to the MSVC
version of the function; MSVCRT contains a lot of the POSIX functions, but
they're all not-quite fully compatible, so they are prefixed with an '_' to
distinguish them. These functions are also available using MinGW, but you
don't want to use them on Cygwin; remove the underscore and use the native
However, the real problem in this case is that there is a prototype for
stat(), but none for _stat(), in the include headers:
> $ gcc -o statex statex.c --save-temps -g3 -gstabs+ -W -Wall
> statex.c: In function 'main':
> statex.c:9: warning: implicit declaration of function '_stat'
Somehow, this bypasses some kind of hidden internal magic that (?i think?)
substitutes the 64-bit version of stat for the regular one, and things go
downhill from there. Moral of the story: *always* compile with warnings
enabled, even for trivial test programs!
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple