I think this happens because popen
is not standard ISO C++ (it comes from POSIX.1-2001).
You could try with:
$ g++ -std=c++11 -U__STRICT_ANSI__ test.cpp
(-U
cancels any previous definition of a macro, either built in or provided with a -D
option)
or
$ g++ -std=gnu++11 test.cpp
(GCC defines __STRICT_ANSI__
if and only if the -ansi
switch, or a -std
switch specifying strict conformance to some version of ISO C or ISO C++, was specified when GCC was invoked)
Playing with the _POSIX_SOURCE
/ _POSIX_C_SOURCE
macros is a possible alternative (http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html).