Does C++20 mandate source code being stored in files?

前端 未结 2 1794
野趣味
野趣味 2021-01-31 06:35

A slightly strange question, however, if I remember correctly, C++ source code doesn\'t require a file system to store its files.

Having a compiler that scans handwritte

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-31 07:12

    Even before C++20, the standard has had:

    __FILE__
    

    The presumed name of the current source file (a character string literal).

    The definition is the same for source_location::file_name.

    As such, there has not been a change in regard to support for file system-less implementations in C++20.

    The standard doesn't exactly define what "source file" means, so whether it refers to a file system may be up to interpretation. Presumably, it could be conforming for an implementation to produce "the handwritten note that you gave to me just then" if that indeed identifies the "source file" in that implementation of the language.


    In conclusion: Yeah, sources are referred to as "files" by the standard, but what a "file" is and whether a file system is involved is unspecified.

提交回复
热议问题