S_ISREG 宏未定义 [英] S_ISREG macro undefined

查看:29
本文介绍了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

      显然 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天全站免登陆