This is the mail archive of the
mailing list for the Cygwin project.
Re: I cannot understand popen/_popen absence
On 2017-01-28 18:16, Пётр Б. wrote:
> Excuse me for vague wording, let me explain it.
> I am trying to build Qt under Cygwin. For some mysterious reason
> Cygwin compiler does not expose popen with std=c++11 which is
> required for Qt
> at the same time the MinGW compiler installed from Cygwin repository
> does expose popen with same standard flag.
> I did not yet find a convenient way of using MinGW compiler (which
> is prefixed) so I am stuggling to get popen exposed.
> What is the reason for this difference between MinGW and Cygwin?
Different default options selected during build.
> 2017-01-29 3:50 GMT+03:00, Пётр Б. <email@example.com>:
>> tchar.h: http://pastebin.com/raw/109n342z
>> So I only get popen if _POSIX_ is defined (which is not defined in
>> any header, I searched Cygwin folder with file manager).
>> stdio.h: http://pastebin.com/raw/jrd2dmzP
>> So I only get popen if some conditions which I did not hear about
>> are fullfilled. So, what sorcery should I use to get popen?
$ fgrep popen -C2 /usr/include/stdio.h
#if __MISC_VISIBLE || __POSIX_VISIBLE >= 199209
int _EXFUN(pclose, (FILE *));
FILE * _EXFUN(popen, (const char *, const char *));
$ egrep -B1 '#define\s+__(MISC_VISIBLE\s+1|POSIX_VISIBLE\s+199209)' /usr/include/sys/features.h
#define __MISC_VISIBLE 1
#elif (_POSIX_C_SOURCE - 0) >= 2 || defined(_XOPEN_SOURCE)
#define __POSIX_VISIBLE 199209
So you have to #define _DEFAULT_SOURCE 1, _XOPEN_SOURCE 1, or
_POSIX_C_SOURCE 2: some of these may be enabled by using
-std=gnu++1[14yz] instead of -std=c++...;
roughly speaking the latter enables only ISO/IEC 9899:yyyy
standard features and disables POSIX-only features, which
are enabled by using -std=gnu++...
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple