Skip to content

Commit 3d5db69

Browse files
authored
Update SYCLACADEMY_ASSERT (#369)
Don't use __assert_fail, this is likely to break on different systems.
1 parent b3be72a commit 3d5db69

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Code_Exercises/helpers.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
#include <cstddef> // for size_t
1414

1515
#ifndef __SYCL_DEVICE_ONLY__
16-
extern "C" void __assert_fail(const char* __assertion, const char* __file,
17-
unsigned int __line, const char* __function);
18-
16+
#include <cstdio> // fprintf
17+
#include <cstdlib> // abort
1918
#define SYCLACADEMY_ASSERT(cond) \
20-
(static_cast<bool>(cond) \
21-
? void(0) \
22-
: __assert_fail(#cond, __FILE__, __LINE__, __FUNCTION__))
19+
if (!(cond)) { \
20+
std::fprintf(stderr, "%s failed in %s:%d:%s\nExiting\n", #cond, \
21+
__BASE_FILE__, __LINE__, __FUNCTION__); \
22+
std::abort(); \
23+
}
2324
#else
2425
#define SYCLACADEMY_ASSERT(cond) void(0);
2526
#endif

0 commit comments

Comments
 (0)