我有一个功能:
SHFileOperationFunc(string item1, string item2, int operation, CuTest *tc)
它用于执行操作(移动,删除或复制)目录。它工作正常。但我现在正在尝试使用dirent.h中的东西。当我包含文件时,它会导致ShellAPI.h中的东西出现大问题。我在SHFileOperationFunc中使用它。我根据http://www.softagalleria.net/dirent.php获得了dirent.h。
在我包含文件后,我收到如下错误:
error C2065: 'FO_DELETE' : undeclared identifier
error C2065: 'FO_COPY' : undeclared identifier
error C2065: 'FO_DELETE' : undeclared identifier
error C2065: 'FO_DELETE' : undeclared identifier
这些在ShellAPI.h中定义。当我在VS中将它们悬停在它们上面时,它会显示它们具有的值,因此它会看到它们。任何人都知道包含此文件的原因是什么?
答案 0 :(得分:2)
在Windows机器上使用dirent.h是不可取的,它是一个Unix标头。您下载的文件会破坏其余的#includes。如果在 #include <windows.h>
之后放置或编辑文件并删除#define for WIN32_LEAN_AND_MEAN。把它放在标题中是很好的意思。它会导致在Windows标头中跳过大量声明。