为什么 Clion 不识别 WxPuts? [英] Why doesn't Clion recognise WxPuts?
问题描述
本教程中使用的 wxPuts 方法(http://zetcode.com/gui/wxwidgets/helperclasses/) 不起作用.是否已更改并且课程不再可用?
The wxPuts method used in this tutorial (http://zetcode.com/gui/wxwidgets/helperclasses/) doesn't work. Was it changed and the class is no longer available?
我尝试在网上搜索有关 wxPuts 和 wxPrintf 的一些文档,但在 wxWidg 站点的帮助文件中找不到任何相关内容.
I tried searching online for some documentation about wxPuts and wxPrintf, but can't find anything relevant in the helper files in the wxWidg site.
#include <wx/textfile.h>
int main(int argc, char **argv)
{
wxTextFile file(wxT("test.c"));
file.Open();
wxPrintf(wxT("Number of lines: %d\n"), file.GetLineCount());
wxPrintf(wxT("First line: %s\n"), file.GetFirstLine().c_str());
wxPrintf(wxT("Last line: %s\n"), file.GetLastLine().c_str());
wxPuts(wxT("-------------------------------------"));
wxString s;
for ( s = file.GetFirstLine(); !file.Eof();
s = file.GetNextLine() )
{
wxPuts(s);
}
file.Close();
}
推荐答案
wxWidgets 为所有处理字符串的标准 CRT 函数提供包装器,以便允许使用 wxString
或 wchar_t调用它们代码>(宽)字符串.这些包装器没有记录,因为重新记录标准函数没有多大意义,但基本上对于标准库中的任何
foo(const char* s)
,你都有 wxFoo(const wxString& s)
在 wx/crt.h
标头中声明.但是,您必须包含此标头才能获得这些声明.
wxWidgets provides wrappers for all standard CRT functions working with strings in order to allow calling them with wxString
or wchar_t
(wide) strings. These wrappers are not documented because it doesn't make much sense to re-document the standard functions, but basically for any foo(const char* s)
in the standard library, you have wxFoo(const wxString& s)
declared in wx/crt.h
header. You have to include this header to get these declarations, however.
另请注意,在 库初始化之前无法使用大部分 wxWidgets 功能.
TL;DR:你错过了 #include <wx/crt.h>
.
TL;DR: you're missing #include <wx/crt.h>
.
这篇关于为什么 Clion 不识别 WxPuts?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!