发送的参数与函数 def 不匹配
parameters sent don't match the function def
我有以下场景,可在Visual c++ 10中工作,但不能在Linux上使用GCC:
调用:
value& v;
wstring fn(L"");
char_conv::str_to_wstr( path, fn );
parse( v, ifstream( fn.c_str() ) ); //<-- ERROR
功能def:
inline std::string parse(value& out, std::istream& is){...}
这是我得到的错误:
In member function ‘std::string PrintInvoker::extractParameter(const std::string&, picojson::value&)’:
error: no matching function for call to ‘std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream(const wchar_t*)’
std::idstream
有以下构造函数:
basic_ifstream();
explicit basic_ifstream( const char* filename,
ios_base::openmode mode = ios_base::in );
explicit basic_ifstream( const string& filename,
ios_base::openmode mode = ios_base::in );
basic_ifstream( basic_ifstream&& other );
basic_ifstream( const basic_ifstream& rhs) = delete;
现在当你调用fn.c_str()
返回一个wchar_t*
因为fn
是一个wstrgin
。正如你所看到的,没有重载需要一个wchar_t*
,所以编译器会给你一个错误。
看看我的MSVS2015副本,似乎微软已经添加了一个构造函数,确实需要一个wchar_t*
,所以这就是为什么它在那里工作,
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么使用 "this" 指针调用派生成员函数?
- 在具有全局类型def的类中使用成员函数指针
- 函数模板签名中忽略的成员类型def 的访问说明符
- 当函数通过.def文件导出时,如何使用dllImport导入函数
- Boost Python def 成员函数,它调用静态函数,其中 self 作为唯一的参数
- 发送的参数与函数 def 不匹配
- 使用def文件从可执行文件导出函数
- 用. def创建DLL来定义函数名
- 在def文件中导出修饰函数名
- 警告:当我在函数def中添加没有实际参数的形式参数时,从字符串常量到' char* '的转换已弃用