public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: cyg Simple <cygsimple@gmail.com>
To: cygwin@cygwin.com
Subject: Re: __STRICT_ANSI__ and stdio.h
Date: Mon, 14 Dec 2015 13:34:00 -0000	[thread overview]
Message-ID: <566EC57B.102@gmail.com> (raw)
In-Reply-To: <CAPYQg33bDtta3=D2bZeswz1zTgrw1m-5rPNRLeayVEY3zp3E0w@mail.gmail.com>

On 12/13/2015 11:56 PM, KIMURA Masaru wrote:
> Hi,
> 
>>> is cygwin's __STRICT_ANSI__ and stdio.h behavior not so compatible to glibc's?
>>> especially, i meant routines in POSIX 1003.1:2001 (popen(), pclose(), etc).
>>> for a specific example, see a cparser issue[1] i submitted.
>>>
>>
>> Cygwin isn't wrong.  __STRICT_ANSI__ doesn't mix with POSIX.
>> __STRICT_ANSI__ definitions is what you should look at for the defined
>> API; not POSIX 1003.1:2001.
> 
> then why does glibc look accepting -std=c99 -D_POSIX_C_SOURCE=200809L?

You'll have to ask glibc why it does this.  That doesn't change the fact
that -std=c99 implies -ansi in gcc.  And you define what ever you like
with -D on the command line; regardless if it is right or wrong.

> so you mean linux (maybe glibc?) is wrong and cygwin (maybe newlib?) is right?

Maybe both are correct and the discrepancy is implementation specific.
Maybe you mean the build of glibc uses the above but glibc is defining
the functions and not just declaring them.  If glibc headers are
declaring popen()/pclose() even if __STRICT_ANSI__ is defined I would
dare to say they are incorrect in implementation.

> 
> w/ attached source that uses popen()/pclose() via gcc -std=c99,
> 

Attaching source code doesn't resolve the fact that popen()/pclose() are
POSIX specific and you've asked for __STRICT_ANSI__ which eliminates the
declarations that are not ANSI specific.

> on cygwin (maybe newlib?), i got,
> p.c: In function ‘main’:
> p.c:5:2: warning: implicit declaration of function ‘popen’
> [-Wimplicit-function-declaration]
>   FILE *pp = popen("cat", "w");
>   ^
> p.c:5:13: warning: initialization makes pointer from integer without a cast
>   FILE *pp = popen("cat", "w");
>              ^
> p.c:12:3: warning: implicit declaration of function ‘pclose’
> [-Wimplicit-function-declaration]
>    int err = pclose(pp);
>    ^
> 
> on linux (maybe glibc?), i got,
> p.c: In function 'main':
> p.c:4:14: warning: unused parameter 'argc' [-Wunused-parameter]
>  int main(int argc, char *argv[]) {
>               ^
> p.c:4:26: warning: unused parameter 'argv' [-Wunused-parameter]
>  int main(int argc, char *argv[]) {
> 
>                           ^                          ^

Again, implementation specifics maybe.  Try with -pedantic to see if it
changes the result.

-- 
cyg Simple

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

  parent reply	other threads:[~2015-12-14 13:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-12  7:51 KIMURA Masaru
2015-12-13 16:51 ` cyg Simple
2015-12-14  4:56   ` KIMURA Masaru
2015-12-14  4:58     ` KIMURA Masaru
2015-12-14 13:34     ` cyg Simple [this message]
2015-12-14 14:06 ` Corinna Vinschen
2015-12-14 17:17   ` KIMURA Masaru
2015-12-15  9:30     ` Corinna Vinschen
2015-12-15 15:58       ` KIMURA Masaru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=566EC57B.102@gmail.com \
    --to=cygsimple@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).