从 VS 2003 迁移到 VS 2008 期间出现的问题
我已将 Visual Studio 2003 项目之一转换为 VS2008,当尝试在 VS2008 中构建该项目时,出现以下错误。
在 oledb.h 中,我有
typedef LONG DBROWCOUNT;
,在 sybdb.h 中,我有
#define DBROWCOUNT 16
当我编译时,出现以下错误:
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(633) : error C2143: syntax error : missing ';' before 'constant'
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(633) : error C2059: syntax error : 'constant'
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(3005) : error C2059: syntax error : 'constant'
如果我注释 //#define DBROWCOUNT 16
,那么这些错误就可以解决,但是我不应该更改代码,所以请帮助我解决这个错误,提前致谢。
I have converted one of my Visual studio 2003 projects into VS2008 and when trying to build the project in VS2008 I get the below mentioned error.
In oledb.h, I have
typedef LONG DBROWCOUNT;
and in sybdb.h, I have
#define DBROWCOUNT 16
When I compile, I get the following errors:
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(633) : error C2143: syntax error : missing ';' before 'constant'
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(633) : error C2059: syntax error : 'constant'
c:\program files\microsoft sdks\windows\v6.0a\include\oledb.h(3005) : error C2059: syntax error : 'constant'
If I comment the //#define DBROWCOUNT 16
, then these errors are solved,but I am not supposed to make changes in code, so please help me to come over this error,thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题似乎是 DBROWCOUNT 被定义为 16,因此它被预处理器替换,导致该行在
预处理后被转换
,这显然是一个错误。 但如果不看代码,我无法说出为什么在 vs2003 中没有发生这种情况。
The problem seems to be that DBROWCOUNT is defined as 16 so it is replaced by preprocessor which results in the line
being converted to
after preprocessing, which is clearly an error. But without looking at the code I can't say why this wasn't happening in vs2003.
虽然我不能说这在 VC 2003 中不是问题,但这里的主要问题是您将 DBROWCOUNT 定义为类型和宏常量(如您所知,这是不允许的。)我们必须在某个地方进行更改,否则您将无法修复编译器错误。 如果 oledb.h 是系统标头,则必须对常量进行更改:
您能否更改
define
宏以读取类似以下内容:然后将
DBROWCOUNT
替换为dbRowCount_k
在代码中将该值用作整数(而不是类型)的位置?While I can't speak to how this was not a problem with VC 2003, the main issues here is that you've defined DBROWCOUNT as both a type and a macro constant (which isn't allowed, as you know.) You're going to have to make a change somewhere, or else you won't be able to fix the compiler error. If oledb.h is a system header, then the change will have to be to your constant:
Can you change that
define
macro to read something like:And then replace
DBROWCOUNT
withdbRowCount_k
in the places in your code where you are using that value as an integer (as opposed to a type)?