我有一个函数:
SHFileOperationFunc(string item1, string item2, int operation, CuTest *tc)它用于执行目录操作(移动、删除或复制)。它工作得很好。但我现在正在尝试使用dirent.h中的内容。当我包含这个文件时,它会导致我在SHFileOperationFunc中使用的ShellAPI.h中的东西出现巨大的问题。根据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中将鼠标悬停在它们上面时,它会显示它们的价值,所以它会看到它们。有人知道为什么包含这个文件会有这样的效果吗?
发布于 2012-02-13 20:33:02
在Windows机器上使用dirent.h是不可取的,它是一个Unix头文件。你下载的文件搞砸了你的#includes的其余部分。可以将if放在#include <windows.h>之后,也可以编辑文件并删除#define for WIN32_LEAN_AND_MEAN。把它放在标题中是,嗯,意思是。它会导致在Windows头中跳过大量声明。
https://stackoverflow.com/questions/9260458
复制相似问题