我创建了一个Global.h文件如下,里面包含了一个全局变量g_sUserDegree。
#ifndef GLOBAL_H_
#define GLOBAL_H_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000#pragma pack (push ,1)
struct USER_DEGREE{
//资料库部分
unsigned IS_FILE_ADD_ACT : 1;
unsigned IS_FILE_ADDBASE : 1;
unsigned IS_FILE_REPEAT : 1;
};
#pragma pack (pop)extern USER_DEGREE g_sUserDegree;#endif------------------------------------------------
可是我Global初始化时VC总是提示我找不到USER_DEGREE,怎么回事?Global.cpp#include "Global.h"
#include "stdafx.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endifUSER_DEGREE g_sUserDegree;-----------------------------------------------
错误消息:
error C2146: syntax error : missing ';' before identifier 'g_sUserDegree'
error C2501: 'USER_DEGREE' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
#ifndef GLOBAL_H_
#define GLOBAL_H_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000#pragma pack (push ,1)
struct USER_DEGREE{
//资料库部分
unsigned IS_FILE_ADD_ACT : 1;
unsigned IS_FILE_ADDBASE : 1;
unsigned IS_FILE_REPEAT : 1;
};
#pragma pack (pop)extern USER_DEGREE g_sUserDegree;#endif------------------------------------------------
可是我Global初始化时VC总是提示我找不到USER_DEGREE,怎么回事?Global.cpp#include "Global.h"
#include "stdafx.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endifUSER_DEGREE g_sUserDegree;-----------------------------------------------
错误消息:
error C2146: syntax error : missing ';' before identifier 'g_sUserDegree'
error C2501: 'USER_DEGREE' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found
解决方案 »
- 需要包含头文件时,在Vc6.0中的设置问题
- ocx打包给WEB用,出错
- 凌晨3点了。。问下:我在设计完成端口服务器。最后肯定要检测性能,cpu使用情况和内存使用情况,是否有碎片等等。我用啥工具来检测?任务
- 该死的MSDN!谁能帮帮我!(GetMonitorInfo 与 winuser.h)
- 在VC中,怎样用单行编辑器(在线等待)
- 500分求教Lame问题结帖给分:mfkzj请进(1)
- 如何在SQL SERVER触发器中调用存贮过程?
- 关于画图的问题
- openGL中图形叠合显示的问题
- 一个我想不通的问题
- 分多僧少,又刚来不久,只能再开个贴,无他,散
- 高分:在windows2000的本地,向登录上来的终端客户的计算机屏幕上打开一个定制的窗口?
改成USER_DEGREE g_sUserDegree;试试
stdafx.h一定要放在最前面#include "stdafx.h"
#include "Global.h"