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