MSVC错误:4个重载都不能转换所有参数类型

问题描述 投票:0回答:1

我正在尝试从ocltoys编译jugCLer,并克服了除一个之外的所有错误。该怎么办?

代码:

//----------------------------------------------------------------------
// Compile kernel
//----------------------------------------------------------------------

const std::string &kernelFileName = commandLineOpts["kernel"].as<std::string>();
OCLTOY_LOG("Compile OpenCL kernel: " << kernelFileName);

// Read the kernel
const std::string kernelSource = ReadSources(kernelFileName, "jugCLer");

// Create the kernel program
cl::Device &oclDevice = selectedDevices[0];
cl::Context &oclContext = deviceContexts[0];
cl::Program program = cl::Program(oclContext, kernelSource);

日志:

1>------ Build started: Project: jugCLer, Configuration: Release Win32 ------
1>  jugCLer.cpp
1>..\..\ocltoys-unocltoys\jugCLer\jugCLer.cpp(398): error C2665: 'cl::Program::Program' : none of the 4 overloads could convert all the argument types
1>          C:\ATI Stream SDK\ATI Stream SDK v2 Developer\include\CL/cl.hpp(2392): could be 'cl::Program::Program(const cl::Context &,const cl::Program::Sources &,cl_int *)'
1>          while trying to match the argument list '(cl::Context, const std::string)'
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
c++ visual-c++ opencl
1个回答
0
投票

cl.hpp中,有cl :: Program的四个构造函数,其中一个如下。

Program(const Context& context, const STRING_CLASS& source, bool build = false, cl_int* err = NULL)

STRING_CLASS是cl :: string的typedef,它在构造函数中接受c样式的以null结尾的字符串。您可以尝试。

cl::Program program = cl::Program(oclContext, kernelSource.c_str());

在较新的标题cl2.hpp中,字符串是std :: string(using string = std::string)的另一个名称。您可能应该使用此更新标题。

© www.soinside.com 2019 - 2024. All rights reserved.