I have a header file that I am trying to include from another source file using include pre-processor directory. I have tried to use both quoted form as well as angle-braket form, but neither seem to do the job.
The file name is .>"hello.h and a directory where it is searched by the compiler. I have tried to include it like this:
#include <.>"hello.h>#include <.\>"hello.h>#include <.\>\"hello.h>#include ".>"hello.h"#include ".>\"hello.h"
I also tried different C and C++ compilers — clang, gcc, clang++ and g++.
Obviously, none of the above worked or otherwise there would have been no question.
I thought that maybe the name is not legal according to the standard. Unfortunately, I have neither C nor C++ standard specifications on hand. The only authoritative source of information I could find was this MSDN page about #include directive, and GNU C preprocessor documentation, here. GNU's documentation does not say much, MSDN has the following clause, however:
The path-spec is a file name optionally preceded by a directory specification. The file name must name an existing file. The syntax of the path-spec depends on the operating system on which the program is compiled.
I am curious as to what C and C++ standards say about this?
Where do I find those OS-specific rules for C and C++ header file naming requirements? I am particularly interested in OS X, Linux and FreeBSD.
Why escaping < and/or " characters does not work?
How do I include my file?
#include ".>\"hello.h"does work to include a file named.>\"hello.husing Apple clang 4.0 (418.0.60) on OS X. Escaping the quote with a backslash allows the compiler to recognize the string, but the backslash is not removed in forming the file name to open.