This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: __STRICT_ANSI__ and stdio.h
- From: KIMURA Masaru <hiyuh dot root at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 14 Dec 2015 13:57:57 +0900
- Subject: Re: __STRICT_ANSI__ and stdio.h
- Authentication-results: sourceware.org; auth=none
- References: <CAPYQg31yUkpu9oC1cfWTmxaBANBYcd4X18RY9Q+BVpx-o=nLBw at mail dot gmail dot com> <566DA207 dot 3080008 at gmail dot com> <CAPYQg33bDtta3=D2bZeswz1zTgrw1m-5rPNRLeayVEY3zp3E0w at mail dot gmail dot com>
oops!
forgot to attach p.c, so resending now...
> 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?
> so you mean linux (maybe glibc?) is wrong and cygwin (maybe newlib?) is right?
>
> w/ attached source that uses popen()/pclose() via gcc -std=c99,
>
> 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[]) {
>
> ^ ^
>
> Peace,
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
FILE *pp = popen("cat", "w");
assert(pp != NULL);
{
int n = fprintf(pp, "foo\n");
assert(n >= 0);
}
{
int err = pclose(pp);
assert(err != -1);
}
return 0;
}
--
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