我正在嘗試在 C 中使用 PCWSTR(使用帶有 DDK 的 Windows XP Free Build Env 編譯)(我知道這是舊的),我似乎不明白如何讓字串作業。
hKey = NULL;
PCWSTR str = L"test";
給我以下
error C2275: 'PCWSTR' : illegal use of this type as an expression
error C2146: syntax error : missing ';' before identifier 'a'
error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
error C2143: syntax error : missing ';' before 'identifier'
error C2065: 'a' : undeclared identifier
error C4047: '=' : 'int' differs in levels of indirection from 'unsigned short [8]'
我究竟做錯了什么?
uj5u.com熱心網友回復:
在舊版本的 C 中,宣告需要出現在塊中的任何非宣告之前。
所以
hKey = NULL;
PCWSTR str = L"test";
不允許,但是
PCWSTR str;
hKey = NULL;
str = L"test";
和
PCWSTR str = L"test";
hKey = NULL;
將被允許??在一個塊的開始。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/464195.html
