Skip to content

Commit

Permalink
Fix incomplete type in BuildLogType (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasMagnus committed Apr 6, 2022
1 parent 61a5c9a commit 0af4767
Showing 1 changed file with 46 additions and 44 deletions.
90 changes: 46 additions & 44 deletions include/CL/opencl.hpp
Expand Up @@ -2087,51 +2087,7 @@ inline bool operator!=(const Wrapper<T> &lhs, const Wrapper<T> &rhs)
//! \endcond


using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
#if defined(CL_HPP_ENABLE_EXCEPTIONS)
/**
* Exception class for build errors to carry build info
*/
class BuildError : public Error
{
private:
BuildLogType buildLogs;
public:
BuildError(cl_int err, const char * errStr, const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
{
}

BuildLogType getBuildLog() const
{
return buildLogs;
}
};
namespace detail {
static inline cl_int buildErrHandler(
cl_int err,
const char * errStr,
const BuildLogType &buildLogs)
{
if (err != CL_SUCCESS) {
throw BuildError(err, errStr, buildLogs);
}
return err;
}
} // namespace detail

#else
namespace detail {
static inline cl_int buildErrHandler(
cl_int err,
const char * errStr,
const BuildLogType &buildLogs)
{
(void)buildLogs; // suppress unused variable warning
(void)errStr;
return err;
}
} // namespace detail
#endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)


/*! \stuct ImageFormat
Expand Down Expand Up @@ -2441,6 +2397,52 @@ class Device : public detail::Wrapper<cl_device_id>
#endif // defined(CL_HPP_USE_CL_DEVICE_FISSION)
};

using BuildLogType = vector<std::pair<cl::Device, typename detail::param_traits<detail::cl_program_build_info, CL_PROGRAM_BUILD_LOG>::param_type>>;
#if defined(CL_HPP_ENABLE_EXCEPTIONS)
/**
* Exception class for build errors to carry build info
*/
class BuildError : public Error
{
private:
BuildLogType buildLogs;
public:
BuildError(cl_int err, const char * errStr, const BuildLogType &vec) : Error(err, errStr), buildLogs(vec)
{
}

BuildLogType getBuildLog() const
{
return buildLogs;
}
};
namespace detail {
static inline cl_int buildErrHandler(
cl_int err,
const char * errStr,
const BuildLogType &buildLogs)
{
if (err != CL_SUCCESS) {
throw BuildError(err, errStr, buildLogs);
}
return err;
}
} // namespace detail

#else
namespace detail {
static inline cl_int buildErrHandler(
cl_int err,
const char * errStr,
const BuildLogType &buildLogs)
{
(void)buildLogs; // suppress unused variable warning
(void)errStr;
return err;
}
} // namespace detail
#endif // #if defined(CL_HPP_ENABLE_EXCEPTIONS)

CL_HPP_DEFINE_STATIC_MEMBER_ std::once_flag Device::default_initialized_;
CL_HPP_DEFINE_STATIC_MEMBER_ Device Device::default_;
CL_HPP_DEFINE_STATIC_MEMBER_ cl_int Device::default_error_ = CL_SUCCESS;
Expand Down

0 comments on commit 0af4767

Please sign in to comment.