Skip to content

Commit 31f880a

Browse files
committed
Turned the static_assert() into a warning/message
Signed-off-by: Vyacheslav N Klochkov <vyacheslav.n.klochkov@intel.com>
1 parent 373bbb6 commit 31f880a

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

sycl/include/CL/sycl/stl.hpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,28 @@
2222
__SYCL_INLINE_NAMESPACE(cl) {
2323
namespace sycl {
2424

25-
#if defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__)
26-
namespace detail {
25+
#if defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)
2726
// SYCL library is designed such a way that STL objects cross DLL boundary,
28-
// which is not guaranteed to work and considered not safe in general.
29-
// Only using same dynamic C++ runtime library for sycl[d].dll and for
30-
// the application using sycl[d].dll is guaranteed to work properly.
31-
constexpr bool isMSVCDynamicCXXRuntime() {
27+
// which is guaranteed to work properly only when the application uses the same
28+
// C++ runtime that SYCL library uses.
29+
// The appplications using sycl.dll must be linked with dynamic/release C++ MSVC
30+
// runtime, i.e. be compiled with /MD switch. Similarly, the applications using
31+
// sycld.dll must be linked with dynamic/debug C++ runtime and be compiled with
32+
// /MDd switch.
33+
// Compiler automatically adds /MD or /MDd when -fsycl switch is used.
3234
// The options /MD and /MDd that make the code to use dynamic runtime also
3335
// define the _DLL macro.
34-
#ifdef _DLL
35-
return true;
36+
#if defined(_MSC_VER)
37+
#pragma message( \
38+
"SYCL library is designed to work safely with dynamic C++ runtime." \
39+
"Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, " \
40+
"or -fsycl switch to set C++ runtime automatically.")
3641
#else
37-
return false;
42+
#warning "SYCL library is designed to work safely with dynamic C++ runtime."\
43+
"Please use /MD switch with sycl.dll, /MDd switch with sycld.dll, "\
44+
"or -fsycl switch to set C++ runtime automatically."
3845
#endif
39-
}
40-
static_assert(isMSVCDynamicCXXRuntime(),
41-
"SYCL library is designed to work with dynamic C++ runtime, "
42-
"please use /MD or /MDd switches.");
43-
} // namespace detail
44-
#endif // defined(_WIN32) && !defined(__SYCL_DEVICE_ONLY__)
46+
#endif // defined(_WIN32) && !defined(_DLL) && !defined(__SYCL_DEVICE_ONLY__)
4547

4648
template <class T, class Alloc = std::allocator<T>>
4749
using vector_class = std::vector<T, Alloc>;
@@ -68,6 +70,5 @@ unique_ptr_class<T> make_unique_ptr(ArgsT &&... Args) {
6870
return unique_ptr_class<T>(new T(std::forward<ArgsT>(Args)...));
6971
}
7072

71-
} // sycl
72-
} // cl
73-
73+
} // namespace sycl
74+
} // __SYCL_INLINE_NAMESPACE(cl)

0 commit comments

Comments
 (0)