草庐IT

alias_wchar_t

全部标签

c++ - WCHAR wszFoo[CONSTANT_BAR] = {0}; <-- {0} 是什么意思?

WCHARwszFoo[CONSTANT_BAR]={0};我从未见过像{0}这样的东西在C++中用作语言的一部分。而且我不知道如何在线搜索这样的问题。这是什么? 最佳答案 参见arrayinitialization.MissinginitializationvaluesusezeroIfanexplicitarraysizeisspecified,butanshorterinitiliazationlistisspecified,theunspecifiedelementsaresettozero.floatpressure[10

c++ - 无法将 QString 转换为 WChar 数组

QStringprocessName="test.exe";QString::toWCharArray(processName);我收到以下错误:error:C2664:'QString::toWCharArray':cannotconvertparameter1from'QString'to'wchar_t*'Nouser-defined-conversionoperatoravailablethatcanperformthisconversion,ortheoperatorcannotbecalled 最佳答案 您使用不当。您应

C++ 编译错误 : "cast from ' WCHAR *' to ' WORD' loses precision"

MyGUI库。源码中有一行:mHandle=(size_t)::LoadCursor(NULL,MAKEINTRESOURCE(IDC_ARROW));mHandle是size_tLoadCursor返回HCURSOR。错误:D:\Dev\MyGUI_3.2.0_RC1\Common\Input\Win32\ResourceW32Pointer.cpp:48:error:castfrom'WCHAR*'to'WORD'losesprecision这是完整的来源:www.pastebin.com/gzqLBFh9MinGW编译器。有错误castfrom'CHAR*'to'WORD'los

c++ - 字符串隐式转换运算符到 const char*/wchar_t *

我发现MFC/ATLCString类在Win32C++代码中非常方便;特别是我发现我们可以将CString的实例直接传递给Win32API的LPCWSTR(即constwchar_t*)参数很方便,感谢CString定义的隐式转换运算符。相反,当使用std::wstring时,需要显式调用.c_str()方法。那么,为什么STL字符串类(std::string和std::wstring)需要显式方法调用(c_str())而不是定义一个隐式的constchar*/constwchar_t*转换运算符?隐式转换运算符是否隐藏着严重的陷阱? 最佳答案

c++ - 从 QString 获取 "const wchar_t*"最快的方法是什么

我想将一个QString变量传递给一个带有constwchar_t*参数的函数。安全的解决方案是:voidfoo(constwchar_t*);QStringx="test";foo(x.toStdWString().c_str());但它有转换为wstring的开销。有没有更快的解决方案?这个解决方案怎么样?安全便携吗?foo(reinterpret_cast(x.constData())); 最佳答案 不,重新解释转换是不安全的,并且在编码不同的某些平台上不起作用。QChar是16位的,内部编码是UTF-16,但是在Linux上

c++ - MacOS clang 通过 Homebrew 在 Mojave `wchar.h` 下损坏

这个问题在这里已经有了答案:'wchar.h'filenotfound(9个回答)关闭去年。毫不奇怪,OSXMojave的新更新破坏了我在Homebrew中的llvm安装,这些是我尝试的步骤:xcode-select--install#Complained,soIinstalledcommandLineToolsfromherehttps://developer.apple.com/download/more/xcode-select-p/Library/Developer/CommandLineToolsxcode-select--install#Nowsaysinstalledsu

c++ - 在不使用构造函数的情况下将 WCHAR* 转换为 wstring

我有一个wchar数组,我需要使用winapi函数将数据写入其中,我想在std::wstring中获取它,我知道std::wstringt(wText);有效,但我不能在if语句中声明它,因为它不会存在于该范围之外。我也不能以这种方式调用构造函数:WCHARwText[256];std::wstringt=L"";if(somecondition){t=t(wText);}我能做什么?当不满足条件时,我希望wstring等于"",当条件满足时,我想将一个WCHAR数组放入其中。 最佳答案 您可以通过在表达式中调用构造函数来构造一个临

c++ - 无法在 MFC/C++ 项目中将参数 1 从 'const wchar_t *' 转换为 'LPCTSTR'

我在线上遇到编译错误:MessageBox(e.getAllExceptionStr().c_str(),_T("Errorinitializingthesoundplayer"));Error4errorC2664:'CWnd::MessageBoxA':cannotconvertparameter1from'constwchar_t*'to'LPCTSTR'c:\users\daniel\documents\visualstudio2012\projects\mytest1\mytest1\main1.cpp1411MyTest1我不知道如何解决这个错误,我尝试了以下方法:Mess

c++ - boost::filesystem::path::native() 返回 std::basic_string<wchar_t> 而不是 std::basic_string<char>

尽管以下代码可以在Linux上编译,但我无法在Windows上编译它:boost::filesystem::pathdefaultSaveFilePath(base_directory);defaultSaveFilePath=defaultSaveFilePath/"defaultfile.name";conststd::strings=defaultSaveFilePath.native();returnsave(s);其中base_directory是一个类的属性,它的类型是std::string,而函数save只需要一个conststd::string&作为参数。编译器提示第三

ios - @compatibility_alias 和 typedef 在 Objective-C 中的 @class 上使用有什么区别

有什么区别:@compatibility_aliasAliasClassNameExistingClassName和typedefExistingClassNameAliasClassName; 最佳答案 https://gcc.gnu.org/onlinedocs/gcc-4.5.4/gcc/compatibility_005falias.html@compatibility_alias仅适用于objc的类typedef是C语言的关键字,它用于任何数据类型。所以,对于你的问题,类名的别名有相同的用途ps:使用@compatibil