delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/11/13:41:37

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4AD21C3C.6050403@gmail.com>
Date: Sun, 11 Oct 2009 18:56:12 +0100
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: [warning: implicit declaration of function] if enable flag std=c99
References: <1962f7960910110923m65e71070oec8f5eec26da114a AT mail DOT gmail DOT com> <416096c60910110940s4ab76378o81a631dac4b5669a AT mail DOT gmail DOT com> <1962f7960910110945g4041b45bu5c8663a17cf0e07f AT mail DOT gmail DOT com> <416096c60910110958v4692ec82v2b4f845a8e63947b AT mail DOT gmail DOT com>
In-Reply-To: <416096c60910110958v4692ec82v2b4f845a8e63947b@mail.gmail.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

Andy Koppe wrote:
> 2009/10/11 Salvatore Santagati:
>> Nope, but under Linux works as well ( with and without std=c99 ) ,
>> under cygwin if enable std=c99
>> I've these type of warning ( source code here is only an example )
> 
> Seems Linux has got it wrong then, because ftello and fseeko are not
> standard C99 functions. Use -std=gnu99 to enable GNU extensions.

  This is most likely a variant of the same problem as with snprintf:

     http://www.cygwin.com/ml/cygwin/2009-04/threads.html#00435

  Selecting --std=c99 causes __STRICT_ANSI__ to be defined.  These functions
are not in c99, so the declarations are wrapped in #ifndef __STRICT_ANSI__.
As the GCC manual says (under '-ansi'):

>    The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
>    is used.  Some header files may notice this macro and refrain from
>    declaring certain functions or defining certain macros that the
>    ISO standard doesn't call for; this is to avoid interfering with
>    any programs that might use these names for other things.

  If you use --std=c99, that means you want *only* c99 functions, and have
specifically asked to be warned about non-ANSI functions.  I don't understand
why Linux does things differently, it's probably technically wrong but trying
to be helpful, but the fact is that if you write a program strictly according
to the c99 standard, you can't expect there to be a library function called
fseeko and you might in fact expect to be able to use that name for a function
in your own code without any clashes (since the c99 spec doesn't say it is
reserved).

  As a workaround you could use --std=gnu99, which gets you c99 + GCC
extension features but doesn't define __STRICT_ANSI__, or drop it altogether;
what's best depends why you're using the flag in the first place.

  The longterm fix is to mark up the newlib headers, looking for "#ifndef
__STRICT_ANSI__" and deciding where to add "|| __STDC_VERSION__ >= 199901L"


    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