Skip to content

Commit dd212a7

Browse files
Add support for custom exception types with CL_HPP_CUSTOM_EXCEPTION_TYPE (#315)
1 parent 59daec6 commit dd212a7

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

include/CL/opencl.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
* Enable exceptions for use in the C++ bindings header. This is the
174174
* preferred error handling mechanism but is not required.
175175
*
176+
* - CL_HPP_CUSTOM_EXCEPTION_TYPE
177+
*
178+
* Specify the type which should be used for exceptions. This type
179+
* must have a constructor accepting an int and a const char*.
180+
*
176181
* - CL_HPP_ENABLE_SIZE_T_COMPATIBILITY
177182
*
178183
* Backward compatibility option to support cl.hpp-style size_t
@@ -748,6 +753,7 @@ namespace cl {
748753
#endif // cl_khr_command_buffer
749754

750755
#if defined(CL_HPP_ENABLE_EXCEPTIONS)
756+
#if !defined(CL_HPP_CUSTOM_EXCEPTION_TYPE)
751757
/*! \brief Exception class
752758
*
753759
* This may be thrown by API functions when CL_HPP_ENABLE_EXCEPTIONS is defined.
@@ -790,6 +796,9 @@ namespace cl {
790796
*/
791797
cl_int err(void) const { return err_; }
792798
};
799+
#else
800+
using Error = CL_HPP_CUSTOM_EXCEPTION_TYPE;
801+
#endif
793802
#define CL_HPP_ERR_STR_(x) #x
794803
#else
795804
#define CL_HPP_ERR_STR_(x) nullptr

0 commit comments

Comments
 (0)