简体   繁体   English

dirent.h使用ShellAPI.h来解决问题

[英]dirent.h casuing problems with ShellAPI.h

I have a function: 我有一个功能:

SHFileOperationFunc(string item1, string item2, int operation, CuTest *tc)

It is used to do operations (move, delete or copy) directories. 它用于执行操作(移动,删除或复制)目录。 It works fine. 它工作正常。 But i am now trying to use stuff from dirent.h. 但我现在正在尝试使用dirent.h中的东西。 When I include the file it causes huge problems with stuff from ShellAPI.h I use in SHFileOperationFunc. 当我包含文件时,它会导致ShellAPI.h中的东西出现大问题。我在SHFileOperationFunc中使用它。 I got dirent.h as per http://www.softagalleria.net/dirent.php . 我根据http://www.softagalleria.net/dirent.php得到了dirent.h。

After I include the file I get errors like: 我包含文件后,我收到如下错误:

error C2065: 'FO_DELETE' : undeclared identifier
error C2065: 'FO_COPY' : undeclared identifier
error C2065: 'FO_DELETE' : undeclared identifier
error C2065: 'FO_DELETE' : undeclared identifier

These are defined in ShellAPI.h. 这些在ShellAPI.h中定义。 When I hover over them in VS it says the value they have so it is seeing them. 当我在VS中将它们悬停在它们上面时,它会显示它们具有的值,因此它会看到它们。 Anyone know why including this file is having this effect? 任何人都知道包含此文件的原因是什么?

Using dirent.h on a Windows machine is unadvisable, it is a Unix header. 在Windows机器上使用dirent.h是不可取的,它是一个Unix头。 The file you downloaded screws up the rest of your #includes. 您下载的文件会破坏其余的#includes。 Either put if after #include <windows.h> or edit the file and delete the #define for WIN32_LEAN_AND_MEAN. 如果 #include <windows.h> 之后放置或者编辑文件并删除#define for WIN32_LEAN_AND_MEAN。 Putting that in a header is, well, mean. 把它放在标题中是很好的意思。 It causes a large number of declarations to be skipped in the Windows headers. 它会导致在Windows标头中跳过大量声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM