vs的c 移植到linux,c – 将VS移植到linux:没有用于调用的匹配函数

我正在尝试移植使用visual studio和linux gcc4.6编译好的代码抛出这个:

PieMenu.cpp: In member function ‘void PieMenu::AddButtons()’:

error: no matching function for call to ‘std::basic_ifstream::open(const wchar_t*)’

PieMenu.cpp:110:44: note: candidate is:

/usr/include/c++/4.6/fstream:531:7: note: void std::basic_ifstream<_chart _traits>::open(const char*, std::ios_base::openmode) [with _CharT = char, _Traits = std::char_traits, std::ios_base::openmode = std::_Ios_Openmode]

/usr/include/c++/4.6/fstream:531:7: note: no known conversion for argument 1 from ‘const wchar_t*’ to ‘const char*’

这是.cpp的相关部分:

void PieMenu::AddButtons()

{

CString slash = CUtils::Slash();

CString texturePath,namelistPath=m_pluginPath;

#ifndef linux

texturePath = L".." + slash + L".." + slash; // On windows plugin is located two levels below...

namelistPath += texturePath;

#endif

texturePath += L"data" +slash+ m_folderpath + slash + L"textures" + slash;

namelistPath += L"data" +slash+ m_folderpath + slash + m_folderpath + L".txt";

for(int i=0;i

{

CString bPath = texturePath + m_folderpath + CString(i);

m_buttons.push_back(ToolButton());

m_buttons[i].Setup( bPath.GetWideString(), i);

}

string l_str;

ifstream infile;

这是代码的第110行:

infile.open (namelistPath.GetWideString());

int k=0;

while(!infile.eof() && k < m_buttonCount) // To get you all the lines.

{

std::getline(infile,l_str); // Saves the line in STRING.

m_buttons[k].SetName(CString(l_str.data()));

k++;

}

infile.close();

}

所有提示和帮助表示赞赏!

解决方法:

C标准库没有为文件流定义open()函数,文件名为宽字符,与流是否用于宽字符无关.也就是说,如果您想要将宽字符串用作文件名,则需要将其转换为合适的字符序列.如何以理想的方式执行此操作取决于您的需求.

从它的外观来看,Windows实现了一种使用宽字符串打开文件的方法,并且它们的标准C库支持扩展,允许您使用宽调用open()(或者只调用open()的文件流的构造函数)字符串.

标签:c,gcc,visual-studio-2010

来源: https://codeday.me/bug/20190729/1570972.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值