有没有办法让 OpenCL C++ 绑定对所有错误都抛出异常?

Is there a way to enable OpenCL C++ bindings to throw exceptions for all errors?

根据主题,OpenCL 的 C++ API 并不总是 throw 以防出错。

例如,调用 cl::Program::buildcl::Kernel::setArg 或传递错误代码指针(可选)时,必须检查 return 值 and/or 错误代码构建 cl::Kernel.

有没有办法启用 总是抛出错误 行为? 也许是预处理器宏或类似的东西?

谢谢!

在撰写本文时,当前版本为 OpenCL 2.2。从这个版本开始,在 GitHub 的 Khronos Group 存储库中找不到 preprocessor macro neither pragmas nor build-time flags for that kind of always throw on error behavior. However, the source code,如果你 真的 想要那种行为,你最好的选择是添加自己或要求。