delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/02/27/18:02:52

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Message-ID: <4B895C30.10708@gmail.com>
Date: Sat, 27 Feb 2010 17:53:52 +0000
From: Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Problem in calling _stat() on Cygwin 1.7
References: <21202 DOT 67532 DOT qm AT web19007 DOT mail DOT hk2 DOT yahoo DOT com>
In-Reply-To: <21202.67532.qm@web19007.mail.hk2.yahoo.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Note-from-DJ: This may be spam

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
POSIX version.

  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!

    cheers,
      DaveK



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019