A preprocessing directive of the form
(that does not match the previous form) is permitted
. The preprocessing tokens after
embed in the directive are processed
just as in normal text (i.e., each identifier currently defined as a macro
name is replaced by its replacement list of preprocessing tokens)
. Then, an attempt is made to form a
preprocessing token (
[lex.header]) from the whitespace and the characters
of the spellings of the resulting sequence of preprocessing tokens immediately after
embed;
the treatment of whitespace
is
implementation-defined
. If the attempt succeeds, the directive with the so-formed
is processed as specified for the previous form
. Otherwise, the program is ill-formed
.
Any further processing as in normal text described for the previous
form is not performed
. [
Note 3:
That is, processing as in normal text happens once and only once for the entire
directive
. —
end note]
[
Example 4:
If the directive matches the second form, the whole directive is replaced
. If the directive matches the first form, everything after the
is replaced
. #define EMPTY
#define X myfile
#define Y rsc
#define Z 42
#embed <myfile.rsc> prefix(Z)
#embed EMPTY <X.Y> prefix(Z)
is equivalent to:
#embed <myfile.rsc> prefix(42)
#embed <myfile.rsc> prefix(42)
—
end example]
[
Example 1:
#undef DATA_LIMIT
#if __has_embed(<data.dat> limit(DATA_LIMIT))
#endif
#if __has_embed(<data.dat> limit(0)
#endif
— end example]
[
Example 2:
#embed <data.dat> limit(__has_include("a.h")
#if __has_embed(<data.dat> limit(__has_include("a.h")
#endif
—
end example]
The
constant-expression shall be an integral constant expression
whose value is greater than or equal to zero
. [
Example 3:
constexpr unsigned char sound_signature[] = {
#embed <sdk/jump.wav> limit(2+2)
};
static_assert(sizeof(sound_signature) == 4);
—
end example]
Otherwise, the
pp-balanced-token-seq is placed immediately
before the comma-delimited list of integral literals
. Otherwise, the
pp-balanced-token-seq is placed immediately after
the comma-delimited list of the integral constant expressions
. [
Example 1:
constexpr unsigned char whl[] = {
#embed "ches.glsl" \
prefix(0xEF, 0xBB, 0xBF, ) \
suffix(,)
0
};
constexpr bool is_empty = sizeof(whl) == 1 && whl[0] == '\0';
constexpr bool is_not_empty = sizeof(whl) >= 4
&& whl[sizeof(whl) - 1] == '\0'
&& whl[0] == '\xEF' && whl[1] == '\xBB' && whl[2] == '\xBF';
static_assert(is_empty || is_not_empty);
—
end example]
[
Example 1:
limit(0) affects when a resource is considered empty
. Therefore, the following program:
#embed </owo/uwurandom> \
if_empty(42203) limit(0)
expands to
42203
—
end example]
[
Example 2:
This resource is considered empty due to the
limit(0) embed-parameter,
always, including in
__has_embed clauses
.int infinity_zero () {
#if __has_embed(</owo/uwurandom> limit(0) prefix(some tokens)) == __STDC_EMBED_EMPTY__
return 0;
#else
#error "The resource does not exist"
#endif
}
— end example]