2010-06-01 168 views
4

当我在VS2010项目中包含一个标准库时,会出现类似这样的错误(这些错误来自shellapi.h)。在类似WINDOWS.HWininet.h或类似的东西加入,当我得到类似的错误。VS2010包含标准库时出现大量错误

1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(56): error C2065: 'HDROP' : undeclared identifier 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(56): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C2144: syntax error : 'int' should be preceded by ';' 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C2146: syntax error : missing ';' before identifier 'STDAPICALLTYPE' 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C2146: syntax error : missing ';' before identifier 'DragQueryFileA' 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C2065: 'HDROP' : undeclared identifier 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C2146: syntax error : missing ')' before identifier 'hDrop' 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(59): error C2059: syntax error : ')' 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(61): error C2144: syntax error : 'int' should be preceded by ';' 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(61): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\ShellAPI.h(61): error C2086: 'int EXTERN_C' : redefinition 

我确定这只是一个项目设置,但我不知道我需要改变什么设置。我应该从哪里开始?

UPDATE

的解决方案是确保WINDOWS.H首次加载。我不知道它依赖于此。为了将来的参考,我应该在哪里查看依赖关系?

+2

请告诉我们您的所有包括。 – SLaks 2010-06-01 22:05:09

+3

你无法不先#包括WINDOWS.H#包括shellapi.h。让我们看看你的列表,当你开始WINDOWS.H – 2010-06-01 22:11:25

回答

2

发生这种情况时,你包括一个坏了,那么你有一个标准的头,因为你的语法错误,直接进行。例如,如果您忘记了一个半,然后包含另一个标题,该标题将报告语法错误。出于这个原因,你应该总是包含“干净的”头像系统头,然后自己定义的头。

+0

虽然这可能是真实的,它是不是一个好足够的理由在你自己的,包括系统头。我总是首先包含我自己的头文件,然后包含其他库的头文件(供应商,提升等),最后是系统头文件;这有助于确保您编写的头文件可以“独立”,并包含#include语句,用于编译它们自己需要的所有内容。 – aldo 2014-02-07 17:55:46

5

我加入

#include <shellapi.h> 

到我的文件之一,当有这些完全相同的错误。我通过添加

#include <windows.h> 

直接在它之前解决了问题。

(你得爱 - 或者更确切地说, - Windows头不#include他们自己需要的报头。如果我这样做,在我自己的代码,我会得到在由我的上司大喊。 !)

+0

...或者说恨它... +1 – Iuliu 2014-10-24 10:59:47

+0

姿是,你怎么说?abseurd! – Claudiu 2015-04-30 17:44:54

相关问题