Jak*_*son 4 visual-studio-2010
当我在我的VS2010项目中包含一个标准库时,我得到了一些像这样的错误(这些错误来自于shellapi.h中的添加).在添加类似Windows.h或Wininet.h之类的内容时,我会遇到类似的错误.
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
Run Code Online (Sandbox Code Playgroud)
我确定这只是与项目设置有关,但我不知道我需要改变什么设置.我应该从哪里开始?
UPDATE
解决方案是确保首先加载windows.h.我不知道它是依赖于那个.为了将来参考,我应该在哪里看到这种依赖?
添加时我得到了完全相同的错误
#include <shellapi.h>
Run Code Online (Sandbox Code Playgroud)
我的一个文件.我通过添加解决了这个问题
#include <windows.h>
Run Code Online (Sandbox Code Playgroud)
直接在它之前.
(你必须喜欢 - 或者更确切地说,讨厌 - 没有#include自己需要的标题的Windows标题.如果我在自己的代码中这样做,我会被我的上级大吼大叫!)
当你的一个包含被破坏,然后你包含一个标准头时,就会发生这种情况,因为你的语法错误直接继续下去。例如,如果您忘记了 semi,然后包含另一个标头,该标头将报告语法错误。因此,您应该始终首先包含“干净”的标头,例如系统标头,然后是自己定义的标头。
| 归档时间: |
|
| 查看次数: |
4058 次 |
| 最近记录: |