15
Preprocessing directives
[cpp]
15.4
Resource inclusion
[cpp.embed]
15.4.2
Embed parameters
[cpp.embed.param]
15.4.2.1
limit parameter
[cpp.embed.param.limit]
1
#
An
embed-parameter
of the form
limit
(
pp-balanced-token-seq
)
specifies the maximum possible number of elements in the comma-delimited list
.
It shall appear at most once in the
embed-parameter-seq
.
The token
defined
shall not appear in the
constant-expression
.
2
#
The
pp-balanced-token-seq
is evaluated as a
constant-expression
using the rules as described in conditional inclusion (
[cpp.
cond]
), but without being processed as in normal text an additional time
.
[
Example
1
:
#undef
DATA_LIMIT
#if
__has_embed
(
<
data
.
dat
>
limit
(
DATA_LIMIT
)
)
#endif
is equivalent to:
#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"
)
)
)
// ill-formed:
__has_
include
(
[cpp.
cond]
) cannot appear here
#endif
—
end example
]
3
#
The
constant-expression
shall be an integral constant expression whose value is greater than or equal to zero
.
The resource-count (
[cpp.
embed.
gen]
) becomes implementation-resource-count, if the value of the
constant-expression
is greater than implementation-resource-count; otherwise, the value of the
constant-expression
.
[
Example
3
:
constexpr
unsigned
char
sound_signature
[
]
=
{
// a hypothetical resource capable of expanding to four or more elements
#
embed
<
sdk
/
jump
.
wav
>
limit
(
2
+
2
)
}
;
static_assert
(
sizeof
(
sound_signature
)
=
=
4
)
;
// OK
—
end example
]