Skip to content

Commit a85b1c3

Browse files
committed
[SYCL]: Suppress modal error message box on Windows
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent fc30f04 commit a85b1c3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sycl/source/detail/windows_pi.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ namespace detail {
1818
namespace pi {
1919

2020
void *loadOsLibrary(const std::string &PluginPath) {
21-
return (void *)LoadLibraryA(PluginPath.c_str());
21+
// Tells the system to not display the critical-error-handler message box.
22+
// Instead, the system sends the error to the calling process.
23+
// This is crucial for graceful handling of plugins that couldn't be
24+
// loaded, e.g. due to missing native run-times.
25+
// TODO: add reporting in case of an error.
26+
// NOTE: we restore the old mode to not affect user app behavior.
27+
//
28+
UINT SavedMode = SetErrorMode(SEM_FAILCRITICALERRORS);
29+
auto Result = (void *)LoadLibraryA(PluginPath.c_str());
30+
(void)SetErrorMode(SavedMode);
31+
32+
return Result;
2233
}
2334

2435
int unloadOsLibrary(void *Library) {

0 commit comments

Comments
 (0)