Skip to content

Commit

Permalink
Update SYCLACADEMY_ASSERT (#369)
Browse files Browse the repository at this point in the history
Don't use __assert_fail, this is likely to break on different systems.
  • Loading branch information
hdelan authored Nov 13, 2024
1 parent b3be72a commit 3d5db69
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Code_Exercises/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
#include <cstddef> // for size_t

#ifndef __SYCL_DEVICE_ONLY__
extern "C" void __assert_fail(const char* __assertion, const char* __file,
unsigned int __line, const char* __function);

#include <cstdio> // fprintf
#include <cstdlib> // abort
#define SYCLACADEMY_ASSERT(cond) \
(static_cast<bool>(cond) \
? void(0) \
: __assert_fail(#cond, __FILE__, __LINE__, __FUNCTION__))
if (!(cond)) { \
std::fprintf(stderr, "%s failed in %s:%d:%s\nExiting\n", #cond, \
__BASE_FILE__, __LINE__, __FUNCTION__); \
std::abort(); \
}
#else
#define SYCLACADEMY_ASSERT(cond) void(0);
#endif

0 comments on commit 3d5db69

Please sign in to comment.