Dushistov / sdcv

https://dushistov.github.io/sdcv/
GNU General Public License v2.0
294 stars 42 forks source link

Compiling error 'popen' not declared in this scope #40

Open yygcode opened 6 years ago

yygcode commented 6 years ago

My work need windows. I use cygwin64 as terminal. Compile sdcv in cygwin64 would failed with 'popen' not declared error.

This is because popen is not standard ISO C++. The problem can be fix with compiling flag CMAKE_CXX_FLAGS="-USTRICT_ANSI". I suggest that you can add the option '-USTRICT_ANSI' to the file cmake/compiler.cmake: ~$ git diff `diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index cf94ed3..f8ebd58 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -23,7 +23,7 @@ elseif (MSVC) elseif (NOT MSVC) check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11) if (CXX_SUPPORTS_CXX11)

Follows are error details: ~$ git show --oneline 51db56f (HEAD -> master, origin/master, origin/HEAD) Merge pull request #38 from nijel/master ~$ mkdir build; cd build ~$ cmake .. -- The C compiler identification is GNU 6.3.0 -- The CXX compiler identification is GNU 6.3.0 CMake Warning at /usr/share/cmake-3.6.2/Modules/Platform/CYGWIN.cmake:15 (message): CMake no longer defines WIN32 on Cygwin! ... ... -- Configuring done -- Generating done -- Build files have been written to: /cygdrive/e/yanyg-data/git/sdcv/build ~$ make Scanning dependencies of target sdcv [ 12%] Building CXX object CMakeFiles/sdcv.dir/src/sdcv.cpp.o [ 25%] Building CXX object CMakeFiles/sdcv.dir/src/readline.cpp.o [ 37%] Building CXX object CMakeFiles/sdcv.dir/src/libwrapper.cpp.o /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp: In constructor ‘{anonymous}::sdcv_pager::sdcv_pager(bool)’: /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp:299:48: error: ‘popen’ was not declared in this scope if (pager && (output = popen(pager, "w")) == nullptr) { ^ /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp: In destructor ‘{anonymous}::sdcv_pager::~sdcv_pager()’: /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp:309:26: error: ‘pclose’ was not declared in this scope pclose(output); ^ make[2]: [CMakeFiles/sdcv.dir/build.make:111: CMakeFiles/sdcv.dir/src/libwrapper.cpp.o] Error 1 make[1]: [CMakeFiles/Makefile2:100: CMakeFiles/sdcv.dir/all] Error 2 make: *** [Makefile:150: all] Error 2

zheng7fu2 commented 3 years ago

👍