delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/10/11/07:44:28

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: mjD.OBqswBAPbVUxYJaYPvc61jLEnpq8VnBwJGdbEJOPA9xw
Message-ID: <4E942C00.7090009@sbcglobal.net>
Date: Tue, 11 Oct 2011 11:44:00 +0000
From: Greg Chicares <gchicares AT sbcglobal DOT net>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: stdio.h: broken standard compliance.
References: <203df9f173be7f13d23b3e7c0fc831c1 AT 127 DOT 0 DOT 0 DOT 1>
In-Reply-To: <203df9f173be7f13d23b3e7c0fc831c1@127.0.0.1>
X-IsSubscribed: yes
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

On 2011-10-10 18:42Z, Kaz Kylheku wrote:
> 
> Corinna Vinschen writes:
> 
>> > $ gcc -Wall -ansi -D_POSIX_C_SOURCE=2 posix-ansi.c
>  ^^^^^
>> fileno and pclose are *not* ANSI functions. Therefore, if you define
>> -ansi, you get the below errors. The newlib headers have explicit
>> #ifndef __STRICT_ANSI__ guards around the non-ANSI definitions.
[...]
> I do not believe that your interpretation of the applicable standards 
> is
> entirely correct.
> 
> The -ansi flag tells the GNU *compiler* to disable its built-in
> extensions. So for instance the block evaluation syntax
> ({ expr1; ... ; exprn }) won't be available.

It does more than that:
  http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/C-Dialect-Options.html
| 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.

This is a "strictly conforming program" as defined by ISO standard C:
  #include <stdio.h>
  int fileno(int x) {return 3 * x;}
  int main()        {return fileno(2);}
With '-ansi', the posix declaration of fileno() is suppressed; if it
weren't, then that program would fail to compile. See:
  http://gcc.gnu.org/ml/gcc-help/2004-09/msg00280.html
An argument could be made for giving _POSIX_C_SOURCE precedence over
__STRICT_ANSI__ if both are defined; but as long as that's not the
behavior, you might want to undef __STRICT_ANSI__ as appropriate.

--
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