std::system_error on Windows
Bug category
- [*] bug - runtime error
Describe the bug Cannot launch any example, I get the following std::system_error:
struct pipe_deleter {
int operator()(FILE* pipe) const {
if (int status = PCLOSE(pipe); status != -1)
return status;
//throw std::system_error{errno, std::system_category(), "pclose"};
}
};
After commenting out "throw std::system_error", the examples start working.
Steps to Reproduce
- Build matplotplusplus in Development Mode
- Install gnuplot v6
- Try to launch any example
Platform
- [*] cross-platform issue - windows
I don't know. Maybe a different status code is not that bad.
@mikucionisaau ?
Oh well, non-POSIX OS does not behave like POSIX says :-(
I see that there is a nice popen and pclose wrapper in popen.cpp for _WIN32, but it is not setting the errno like POSIX pclose does, so the error gets lost (I get system_error with "Success" with mingw64 and wine setup on Linux).
I do not see any other signs of cross-compilation attempts in this repo, so I was wondering how do you compile? What OS/toolchain/compiler do you use?
What OS/toolchain/compiler do you use?
No cross-compilation, I compile natively on Windows 10, using
Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
Adjusted CMAKE_CXX_COMPILER in cmake presets to "cl" (this is MSVC).
Good news: I found _popen in Windows, which works, so popen.cpp is overly complicated and can be retired, unless there is some old Windows that needs it.
I'll make a PR for this.
Bad news: popen.cpp was created to hide console window to fix https://github.com/alandefreitas/matplotplusplus/issues/376
popen is always causing minor issues over the years 🤣
The fix is almost ready (needs testing and review): https://github.com/alandefreitas/matplotplusplus/pull/428
I would appreciate if @bitsbakery gave it a spin.
It works. Also terminal window no longer appears, as it did with "throw std::system_error" commented out.