Skip to content

Commit

Permalink
Add support for custom exception types with CL_HPP_CUSTOM_EXCEPTION_TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-kiess committed Oct 31, 2024
1 parent a232f10 commit 6cca37d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/CL/opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@
* Enable exceptions for use in the C++ bindings header. This is the
* preferred error handling mechanism but is not required.
*
* - CL_HPP_CUSTOM_EXCEPTION_TYPE
*
* Specify the type which should be used for exceptions. This type
* must have a constructor accepting an int and a const char*.
*
* - CL_HPP_ENABLE_SIZE_T_COMPATIBILITY
*
* Backward compatibility option to support cl.hpp-style size_t
Expand Down Expand Up @@ -748,6 +753,7 @@ namespace cl {
#endif // cl_khr_command_buffer

#if defined(CL_HPP_ENABLE_EXCEPTIONS)
#if !defined(CL_HPP_CUSTOM_EXCEPTION_TYPE)
/*! \brief Exception class
*
* This may be thrown by API functions when CL_HPP_ENABLE_EXCEPTIONS is defined.
Expand Down Expand Up @@ -790,6 +796,9 @@ namespace cl {
*/
cl_int err(void) const { return err_; }
};
#else
using Error = CL_HPP_CUSTOM_EXCEPTION_TYPE;
#endif
#define CL_HPP_ERR_STR_(x) #x
#else
#define CL_HPP_ERR_STR_(x) nullptr
Expand Down

0 comments on commit 6cca37d

Please sign in to comment.