2.9 KiB
[cpp.embed.param.limit]
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]
An embed-parameter of the formlimit ( 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 preprocessing token defined shall not appear in thepp-balanced-token-seq.
The pp-balanced-token-seq is evaluated as aconstant-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]
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 theconstant-expression is greater than implementation-resource-count; otherwise, the value of theconstant-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]