Skip to content

Use _depenv_s in libsyclinterface on Windows #1255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions libsyclinterface/helper/source/dpctl_error_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "dpctl_service.h"
#include <cstring>
#include <sstream>
#ifdef _WIN32
#include <cstdlib>
#endif
#ifdef ENABLE_GLOG
#include <glog/logging.h>
#endif
Expand All @@ -48,9 +51,16 @@ namespace
{
int requested_verbosity_level(void)
{
int requested_level = 0;
char *verbose = nullptr;

#ifdef _WIN32
size_t len = 0;
_dupenv_s(&verbose, &len, "DPCTL_VERBOSITY");
#else
verbose = std::getenv("DPCTL_VERBOSITY");
#endif

const char *verbose = std::getenv("DPCTL_VERBOSITY");
int requested_level = 0;

if (verbose) {
if (!std::strncmp(verbose, "none", 4))
Expand All @@ -61,6 +71,11 @@ int requested_verbosity_level(void)
requested_level = error_level::warning;
}

#ifdef _WIN32
if (verbose)
free(verbose);
#endif

return requested_level;
}

Expand Down