Let's say I have a header file called a"b.h
or a>b.h
, how do I escape the "
or >
character in an include directive?
// this does not work
#include "a\"b.h"
>
character is not allowed as part of filename when using #include <filename>
directive (and respectively, "
is not allowed as part of filename in #include "filename"
). There is no standard way to escape any characters in the sequence, any such feature would be a compiler extension. cppreference link.
For the specific case of filename a>b.h
, you can change it to #include "a>b.h"
and it should work.
Filename a"b.h
is out of luck - even in #include <a"b.h>
it's implementation-defined how "
character is treated (or if supported at all).
Aside from "
, also using characters '
, \
, //
or /*
in filename part of #include
directive is implementation-defined and may be unsupported.