wrote:
>> That's wrong. You can specify characters like space in an #include
>> directive, but how the characters are mapped to actual file names is
>> implementation-defined. IOW: Whether spaces in header file names are
>> allowed depends on the implemenation and is usually determined by the
>> operating system the compiler is running under and the file system the
>> headers are stored in. Under MSDOS e.g., spaces in file names are not
>> allowed, and all compilers that I have seen do a 1:1 mapping of the
>> header-names specified in #include and the actual file names.
>
> 1: under DOS you can have spaces, but not two adjacent or at one at the
>
> beginning or the end of a name (not all programs agree, though)
There may be hacks that still make it possible, but Microsoft's FAT
specification says that spaces are not allowed for short file names (which
is what MSDOS uses).
> 2: IBM's C++ compiler had some weird kind of non-file storage once?
I have heard about that, but don't know any details.
> There is no reason, after all, for headers to be files.
Depends on what you mean by "files". From the C++ standard:
************************************************** **********************
16.2 Source file inclusion
1 A #include directive shall identify a header or source file that can be
processed by the implementation.
************************************************** **********************
So it clearly speaks of "files" in conjunction with headers, and not only in
this place. However, it doesn't define how such a file is stored.
> 3: Nor do translation units have to be files - they don't even need
> preprocessor names!
I don't exactly know what you mean by that.
> 4: Most compilers that I know use something like /I flags to translate
> header file names into filesystem names. Not a straight 1:1 mapping,
> especially if a single name occurs in more than one directory.
This search sequence is not the mapping that the C++ standard is talking
about.
Something more from section 16.2:
************************************************** **********************
3 A preprocessing directive of the form
# include "q-char-sequence" new-line
causes the replacement of that directive by the entire contents of the
source file identified by the specified sequence between the " delimiters.
The named source file is searched for in an implementation-defined
manner. If this search is not supported, or if the search fails, the
directive is reprocessed as if it read
# include <h-char-sequence> new-line
with the identical contained sequence (including > characters, if any)
from the original directive.
************************************************** **********************
So those /I flags are what the C++ standard means by "searched for in an
implementation-defined manner".
> 5: The system headers are even weirder, especially on Unix systems
> where some compiler vendors mix OS and C++ headers.
I haven't seen anything unusual here. They are often using a lot of #defines
and #ifdefs and #include other headers that in turn #include more headers,
but nothing that uses something else than the 1:1 filename mapping.