错误C2146:语法错误:缺少';'在标识符之前 [英] error C2146: syntax error : missing ';' before identifier

查看:961
本文介绍了错误C2146:语法错误:缺少';'在标识符之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
仅供参考,我在我的项目中使用VS2008和Winddk 7.1版本.

我创建了基于MFC对话框的应用程序,编译时工作正常,我包含了一些使用winddk库的文件,并在我的项目设置中添加了Winddk库.它给了我如下所示的错误.

Hi All,
FYI I am using VS2008 and Winddk 7.1 Version in my project.

I create MFC dialog based application.When compiling it is working fine.I Includes some files that uses winddk library and add Winddk library in my projects settings. it gives me error as shown below.

c:\winddk\7600.16385.1\inc\api\ntddstor.h(192) : error C2146: syntax error : missing '';'' before identifier ''DeviceType''
c:\winddk\7600.16385.1\inc\api\ntddstor.h(192) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\winddk\7600.16385.1\inc\api\ntddstor.h(192) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int







My Settings are 
c/c++ General
Additional Include Directories :
C:\Program Files\Microsoft Visual Studio 9.0\VC\include;C:\WinDDK\7600.16385.1\inc\api;
linker General
Additional Library Directory:
C:\Program Files\Microsoft Visual Studio 9.0\VC\lib;
Linker input:
Additional Dependencies:
setupapi.lib newdev.lib



我在基于控制台的应用程序中做到了这一点.
我发现的原因是它无法识别ntddk.h文件,这是由于两个include目录所致.
任何帮助表示赞赏.
预先感谢.



I do this in console based application it is working fine.
The reason i found is that it is not recognizing the ntddk.h file and this is due to two include directory.
Any help is appreciated.
Thanks in advance.

推荐答案

我相信您可以在 \ 7600.16385.1 \ inc \ ddk \ wdm.h 中找到它

I believe you can find this in \7600.16385.1\inc\ddk\wdm.h

#define DEVICE_TYPE ULONG



最好的祝福,
-David Delaune



Best Wishes,
-David Delaune


该错误可能是在 #include<ntddstor.h>
之前 可能在另一个文件的末尾.
或者: ntddstor.h 使用一些您之前未包含在其他地方定义的类型名.

只是为了体验此错误,请尝试编译以下内容:
The error is probably BEFORE the #include<ntddstor.h>
May be at the end of another file.
Or: ntddstor.h use some typenames that shuld be defined somewhere else before, that you did not include.

Just to experience with this error, try to compile this:
//EXAMPLE a
int a //no ; here
B c;




or

//EXAMPLE B
int a;
B c; //c of type B but B not declared


尊重


respect to

//GOOD CASE
typedef int B;
int a;
B c;



并查看编译器错误消息.
现在,假设第一行是" file1.h "的最后一行,第二行是" file2.h "的第一行,并且具有 file.cpp 作为



And look the compiler error message.
Now imagine the first line to be the last of a "file1.h" and the second to be the first of "file2.h", and to have file.cpp as

#include "file1.h"
#include "file2.h"



你明白了吗?



Do you got the point?


这篇关于错误C2146:语法错误:缺少';'在标识符之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆