Skip to content

Commit d396422

Browse files
committed
Teuchos: Fix POSIX code in Teuchos::SystemInformation for Windows compilers
The WIN32 API includes a compatible counterpart to the POSIX functions introduced in the commit referenced in the issue description (popen and pclose). The Windows versions have the same parameters, return type, and behavior, but the function name is different (_popen and _pclose). There is also a correction to the return value from the function std::filesystem::canonical, which is being assigned to a std::string when the function returns a std::filesystem::path.
1 parent bfa0c9f commit d396422

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/teuchos/core/src/Teuchos_SystemInformation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
// needs to be in the global namespace
2525
extern char **environ;
2626
#endif
27+
#if defined(_WIN32)
28+
#include <stdio.h>
29+
FILE *popen(const char *command, const char *mode)
30+
{ return _popen(command, mode); }
31+
32+
int pclose(FILE *stream)
33+
{ return _pclose(stream);}
34+
#endif
2735

2836
namespace Teuchos::SystemInformation {
2937

@@ -213,7 +221,7 @@ void initializeCollection() {
213221

214222
#if !defined(__GNUC__) || (__GNUC__ >= 10)
215223
try {
216-
const std::string executable = std::filesystem::canonical("/proc/self/exe");
224+
const std::string executable = std::filesystem::canonical("/proc/self/exe").string();
217225
if (!executable.empty()) {
218226
registerCommand("ldd", "ldd " + executable, "ldd");
219227
}

0 commit comments

Comments
 (0)