This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __STRICT_ANSI__ and stdio.h


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]