error C2002: invalid wide-character constant

whoo 2003-06-30 08:46:16
我被Bill气死了。

下面是从网上下的源码,编译通不过。报告非法宽字符。

wchar_t szText[80] = L"\xff" L"c2GrabIt activated" ;

经过反复试验,发现是编译器拒绝 \xff 的值。
而且是\x00 ~ \x80 统统可以接受。
\x100 ~ \xffff 也统统可以就收。

唯独 129~255(\x81 ~ \xff), 死活不承认。

请大虾们支支招。

BTW:这是一个工具的源码,工具已经发行了N年了,源码不可能有原则上的错误的。
...全文
525 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
cy214 2003-06-30
  • 打赏
  • 举报
回复

我安装的是英文win2000professional 然后在控制面板中把区域的Set Defaults设置为Chinese(PRC) 再安个紫光拼音 就和中文的系统一样用啦
除了菜单什么的是英文的 不过没什么影响
Office我装的都是英文的 一样用 都没什么问题
我用的是vc6英文版对你的这个工程做的编译 Debug和Release都没事
不过我也不能确定就是系统的事。。
你先直接看代码吧 能编译通过了保证是没问题的
whoo 2003-06-30
  • 打赏
  • 举报
回复
94 diablo2的"无影手"?
我的机器上下载的无法工作,进入游戏时就卡住了,所以想看看他的原码。
whoo 2003-06-30
  • 打赏
  • 举报
回复
哦.....

英文Win2000professional 但是区域设置是中文 。。

工作界面是中文么?平常的中文应用有没有影响?
whoo 2003-06-30
  • 打赏
  • 举报
回复
吐血啊......

cy214(我爱C++), 你的什么系统?vc6 or 7?
cy214 2003-06-30
  • 打赏
  • 举报
回复
不过这程序对我来说比较难看懂
首先winsocket编程就没接触过。。
还是让高人来解释吧
cy214 2003-06-30
  • 打赏
  • 举报
回复
diablo2的"无影手"? 。。
我这里编译 0 errors 0 warnings
估计跟系统有关系
whoo 2003-06-30
  • 打赏
  • 举报
回复
ftp://tingsi.vicp.net:2121/GrabIt_1-2_Source.zip
cy214 2003-06-30
  • 打赏
  • 举报
回复
可以来个源工程的下载地址吗 帮你编译试试。。
whoo 2003-06-30
  • 打赏
  • 举报
回复
估计跟语言有关。我是中文的XP. 但是不知道是什么地方or参数 影响到了这一点。

原码是鬼子发布的。
whoo 2003-06-30
  • 打赏
  • 举报
回复
太长乐,铁不下。 贴一个完整的函数吧。
由于是编译错误,基本可以确定是这儿的原因的。

LRESULT CALLBACK TestWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
break;

// if we get a wm_copydata msg, rock n' roll!!!
case WM_COPYDATA: {

COPYDATASTRUCT *pcds = (COPYDATASTRUCT *)lParam;
BYTE msg[500];
//unsigned long ul=0;
memcpy( &msg, (const unsigned char*)pcds->lpData, pcds->cbData);

/*
if (( msg[0]==0x9C) || ( msg[0]==0x9D) || ( msg[0]==0x07)) {
FILE* fmouse = fopen("dump.txt","a") ;
for (unsigned int i = 0; i < pcds->cbData; i++)
fprintf( fmouse,"%.2X ",msg[i]);
fprintf( fmouse,"\n");
fclose( fmouse) ;
}
*/

if ((int)pcds->dwData >= 0) {
pObject->prg->m_Capturing = !pObject->prg->m_Capturing ;

if (pObject->prg->m_Capturing) {
// wchar_t szText[80] = L"\xff" L"c2GrabIt activated" ;
wchar_t szText[80] = L"\xffff" L"c2GrabIt activated" ;
SendTextToD2(szText);
} else {
wchar_t szText[80] = L"\xff" L"c2GrabIt off" ;
SendTextToD2(szText);
}
}

if (pObject->prg->m_Capturing) {

if ( msg[0]==0x9C) {
// drops and "item here" msgs - see if we should pick
if ( msg[1] <= 0x04)
parseItem( msg) ;

} else if ( msg[0]==0x9D) {
// drops and "item here" msgs - see if we should pick
if ( msg[1] == 0x05)
parseItem( msg) ;

// 0A, 04 means an item was removed from the ground
} else if ( msg[0]==0x0A) {
if ( msg[1] == 0x04)
parseItem( msg) ;

// player coordinates
} else if (msg[0] == 0x96) {
parseMovement( msg) ;
}
}

// copy the data into a seperate buffer
break;

}

default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
whoo 2003-06-30
  • 打赏
  • 举报
回复
晕,那有可能是编译设置的问题了。 不知道那个选项可能影响到这个。

我贴一个CPP的原码吧。
cy214 2003-06-30
  • 打赏
  • 举报
回复
typedef unsigned short wchar_t;
你的这个定义也不会有错吧
那会是什么错误呢?

ps:我的操作系统是英文Win2000professional 但是区域设置是中文 不知道跟操作系统有没有关系
cy214 2003-06-30
  • 打赏
  • 举报
回复
我把你的代码paste到一段函数中 没报错啊
而且我用一个CString指向了这个串 用AfxMessageBox()显示出来的是 ?c2GrabIt activated
笔记本的风扇控制 ---------------------------------------- 09 November 2006. Summary of changes for version 20061109: 1) ACPI CA Core Subsystem: Optimized the Load ASL operator in the case where the source operand is an operation region. Simply map the operation region memory, instead of performing a bytewise read. (Region must be of type SystemMemory, see below.) Fixed the Load ASL operator for the case where the source operand is a region field. A buffer object is also allowed as the source operand. BZ 480 Fixed a problem where the Load ASL operator allowed the source operand to be an operation region of any type. It is now restricted to regions of type SystemMemory, as per the ACPI specification. BZ 481 Additional cleanup and optimizations for the new Table Manager code. AcpiEnable will now fail if all of the required ACPI tables are not loaded (FADT, FACS, DSDT). BZ 477 Added #pragma pack(8/4) to acobject.h to ensure that the structures in this header are always compiled as aligned. The ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work if it is byte-packed. Example Code and Data Size: These are the sizes for the OS- independent acpica.lib produced by the Microsoft Visual C++ 6.0 32- bit compiler. The debug version of the code includes the debug output trace mechanism and has a much larger code and data size. Previous Release: Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total Debug Version: 155.4K Code, 63.1K Data, 218.5K Total Current Release: Non-Debug Version: 77.9K Code, 17.0K Data, 94.9K Total Debug Version: 155.2K Code, 63.1K Data, 218.3K Total 2) iASL Compiler/Disassembler and Tools: Fixed a problem where the presence of the _OSI predefined control method within complex expressions could cause an internal compiler error. AcpiExec: Implemented full region support for multiple address spaces. SpaceId is now part of the REGION object. BZ 429 ---------------------------------------- 11 Oc

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧