c++ - 我应该如何处理:错误 C2039 'assign': is not a member of 'cl::string' in Visual Studio 2017?
问题描述
我想在 Visual Studio C++ 中构建一个简单的 OpenCL 代码,但在构建过程中出现错误。错误是
Error C2039 'assign': is not a member of 'cl::string'
问题是关于cl::string
。std::string
但是,当我使用而不是构建代码时cl::string
,它工作得很好。我应该如何处理?
这是代码:
#define __CL_ENABLE_EXCEPTIONS
#define __NO_STD_STRING
#include <iostream>
#ifdef MAC
#include<OpenCL.hpp>
#else
#include<CL/cl.hpp>
#endif // MAC
int main() {
std::vector < cl::Platform > platforms;
cl::string platformVendorName;
cl::Platform::get(&platforms);
std::cout << "There are " << platforms.size() << " platforms." <<
std::endl << std::endl;
for (size_t j = 0; j < platforms.size(); j++)
{
platformVendorName = platforms[j].getInfo<CL_PLATFORM_VENDOR>();
std::cout << "CL_PLATFORM_VENDOR: " <<
platformVendorName.c_str() << std::endl;
}
system("pause");
return 0;
}
解决方案
为什么不使用 std::string?
至少从 OpenCL 1.2 起,命名空间中string
定义的类已被弃用,不推荐使用它。cl
取自cl.hpp:
/*! \class string
* \brief Simple string class, that provides a limited subset of std::string
* functionality but avoids many of the issues that come with that class.
* \note Deprecated. Please use std::string as default or
* re-define the string class to match the std::string
* interface by defining STRING_CLASS
*/
class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED string CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
推荐阅读
- javascript - 有没有办法防止回发?
- c# - DateTime 列的列表对象上的时间问题
- firebase - Flutter Firebase - 如何将用户 uid 添加到文档
- ocaml - 使用 ocaml OUnit2 assert_raise
- verilog - 可变模块安装
- unit-testing - vertx 单元测试未执行,超时异常
- linux - 有没有更好的方法来读取和附加 bash 脚本中的文件
- python - 如何摆脱 pygame 上的图形伪影?
- scala - 如何为我的无标记代数编写单元测试?
- c# - 如何在 UWP 应用中的主窗口和 AppWindow 之间传输信息?