【问题标题】:Why is errno not found in Visual Studio 6.0?为什么在 Visual Studio 6.0 中找不到 errno?
【发布时间】:2010-07-16 18:10:24
【问题描述】:
#include <errno.h>  
  /* compress until end of file */
  do {
       strm.avail_in = fread(in, 1, CHUNK, source);
       errno; //<-----DEBUGGER "CXX0017: Error: symbol errno not found"  
       perror("Error:");

      if (ferror(source)) //<--ferror = 32 but there is no string from perror? 
      {
         //error handling

【问题讨论】:

    标签: c windows visual-studio winapi


    【解决方案1】:

    当您使用 CRT 的 DLL 版本(例如 /MDd)构建时,errno 是一个宏。将其转换为函数调用以获取 errno 的共享值。像这样修复它:

    int err = errno;
    

    这样你就可以检查 err 的值了。

    【讨论】:

    • 太棒了!谢谢你! ( 错误 = 9 )
    猜你喜欢
    • 2023-03-12
    • 2012-12-06
    • 2011-07-13
    • 1970-01-01
    • 1970-01-01
    • 2020-10-06
    • 2018-03-21
    • 2023-03-30
    • 2014-03-09
    相关资源
    最近更新 更多