Visual C++错误 C2143:语法错误:缺少 ';'在“恒定”之前
虽然该错误与其他人所经历的相同,但我的周围环境是完全不同。我实际上确实尝试声明一个常量:
const long CS_DROPSHADOW = 0x20000;
const long WS_EX_LAYERED = 0x80000;
报告两个常量名称的错误。
常量声明位于头文件中,位于任何类声明之外。
H 文件如下所示:
#ifndef _ASD_SMARTWINDOW_MAIN_H_TAGXXXMAIH_
#define _ASD_SMARTWINDOW_MAIN_H_TAGXXXMAIH_
#include "ASDTail.h" //Queue support.
namespace ASDSmartWindowMaster
{
...
};
class ASDSmartWindowListener
{
};
const long CS_DROPSHADOW = 0x20000;
const long WS_EX_LAYERED = 0x80000;
//Now comes a bunch of enums...
enum KLayeredWindowType
{ ... };
class ASDSmartWindow
{
};
#endif
While the error is identical to what others have experienced, my surroundings are completely different. I actually do try to declare a constant:
const long CS_DROPSHADOW = 0x20000;
const long WS_EX_LAYERED = 0x80000;
The error is reported for the two constant names.
The constants declaration is located in a Header file, outside any class declaration.
Here is how the H file looks like:
#ifndef _ASD_SMARTWINDOW_MAIN_H_TAGXXXMAIH_
#define _ASD_SMARTWINDOW_MAIN_H_TAGXXXMAIH_
#include "ASDTail.h" //Queue support.
namespace ASDSmartWindowMaster
{
...
};
class ASDSmartWindowListener
{
};
const long CS_DROPSHADOW = 0x20000;
const long WS_EX_LAYERED = 0x80000;
//Now comes a bunch of enums...
enum KLayeredWindowType
{ ... };
class ASDSmartWindow
{
};
#endif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CS_DROPSHADOW 和 WS_EX_LAYERED 在 WinUser.h 中声明。
确认您没有将其包含在声明之前。
CS_DROPSHADOW and WS_EX_LAYERED are declared in WinUser.h.
Verify that you didn't include it before your declarations.