代码之家  ›  专栏  ›  技术社区  ›  Rick Jim DeLaHunt

在llvm的stdio.h中哪里可以找到EOF定义?

c++
  •  0
  • Rick Jim DeLaHunt  · 技术社区  · 7 年前

    我正在研究C++的I/O文档。

    EOF 中的定义 stdio.h 但在 标准时间 llvm公司 https://github.com/llvm-mirror/libcxx/blob/master/include/stdio.h

    enter image description here


    顺便说一下,从 https://en.cppreference.com/w/cpp/string/char_traits 上面写着 enter image description here

    char , std::char_traits::eof 退货 EOF公司 哪个是 -1 https://en.cppreference.com/w/cpp/string/char_traits/eof

    返回一个与char\u类型的任何有效值都不相等的值。

    我推断如下: 不是char\u类型的有效值( 烧焦 )?

    怎么会?在VC++中, 烧焦 已经签字了,所以 -1 有效期应为 烧焦 .

    1 回复  |  直到 7 年前
        1
  •  1
  •   Cubbi    7 年前

    你提到的档案, https://github.com/llvm-mirror/libcxx/blob/master/include/stdio.h ,使用以下行从C库中提取EOF:

    #include_next <stdio.h>
    

    LLVM不提供C库,因此它将是您系统上的所有库。例如,在Linux上,它通常是gnulibc,它定义了EOF here

    /* The value returned by fgetc and similar functions to indicate the
       end of the file.  */
    #define EOF (-1)