S_ISREG宏未定义 [英] S_ISREG macro undefined

查看:236
本文介绍了S_ISREG宏未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

  • posix宏仅是S_ISREG,S_ISDIR等linux吗?我需要找出原因,因为我正在尝试编译 CURL ,并且它正在Windows上尝试使用它们
  • 我可以使用哪些包含文件在Windows上访问它们.

    Questions

    • Are the posix macros S_ISREG, S_ISDIR etc linux only? I need to find out because i am trying to compile CURL and it is trying to use them on windows
    • What include file can i use to access them on windows.

      这是令人讨厌的代码

      /*we ignore file size for char/block devices, sockets etc*/
      if(S_ISREG(fileinfo.st_mode))
         uploadfilesize= fileinfo.st_size;
      }
      

      它会导致错误

      error LNK2019: unresolved external symbol _S_ISREG referenced in function _operate file tool_operate.obj
      

      在以下问题中引用了它们

      They are referenced in the following questions

      • How to use S_ISREG() and S_ISDIR() POSIX Macros?
      • Differentiate between a unix directory and file in C and C++
      • Problem reading directories in C

      显然S_ISREG()是posix宏的一部分,显然应该告诉我们文件是否是常规文件",但是我发现的所有示例都具有特定于linux的包含文件.

      Apparently S_ISREG() is part of a bunch of posix macros and is apparently supposed to tell us if a file is a "regular file" but all the examples I found had linux specific include files.

      推荐答案

      在Windows上没有这样的东西,您可以使用FindFirstFile,FindNextFile win32 api,返回结构包含相似但不相同的东西.

      No such thing on windows, you can use the FindFirstFile, FindNextFile win32 api, the return structure contains something similar but not the same.

      如果使用gcc/mingw库,则它们具有stat()模拟.您需要为该宏包含sys/stat.h.

      If you use gcc/mingw library they have a stat() simulation. You need to include sys/stat.h for that macro.

      这篇关于S_ISREG宏未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆