How can I include a header file that contains `>` in its name?

Try below syntax:

#include "weird>name"

So, in C and/or C++, is there a way to include an header file which has the > character in its name?

Yes:

#include "weird>name"

So is there any escaping mechanism to let me include weird>name using the #include <> syntax?

No. The characters between the < and > must be "any member of the source character set except new-line and >" ([lex.header]). Any escaped form of > would still be a way to represent the > character, which is not allowed. Edit: Implementations are allowed to support implementation-defined escape sequences there though (see [lex.header] p2 and its footnote).

The #include " q-char-sequence " form does allow the > character to appear, even though it might get reprocessed as #include <...> if searching as "..." fails ([cpp.include] p3).

The preprocessor also allows another form ([cpp.include] p4](http://eel.is/c++draft/cpp.include#4)), but its effect are implementation-defined, and the implementations I tried do not allow joining weird and > and name into a single preprocessor-token that can then be included


Ask the author of your compiler.

The C and C++ standards grant a lot of leeway to implementations over the interpretation of #include directives. There's no requirement that #include <foo.h> causes the inclusion of a file called "foo.h". For instance, a compiler can choose to ROT13 all the source file names if it likes. And for non-alphanumeric characters, the implementation can identify and remap certain character sequences. So if there were a platform where > regularly showed up in filenames, it's likely that a compiler for that platform would specify that, say, \g or something would be remapped to >. But the standard doesn't mandate a particular encoding.

Incidentally, the implementation could also just choose to allow #include <weird>name>. Since that is not well-formed under the language standards, an implementation is free to define a meaning for it as an extension.