gemini-2.5-flash-preview-09-2025| input-price: 0.3 output-price: 2.5 max-context-length: 128_000 (cost: $0.006) Β· Anfrage: 2025-12-26T17:31:29.063355
Generated by rs-summarizer Version unbekannt
Domain: C Language Standardization / Preprocessor Directives Expert Persona: Senior C Standards Analyst
This documentation outlines the syntax and semantics of the #embed preprocessor directive, introduced in C23 (ISO/IEC 9899:2024) for binary resource inclusion at translation time. The directive facilitates incorporating external data sources by replacing itself with a comma-separated sequence of integer constant expressions. The mechanism employs search paths similar, but distinct, to those used for standard file inclusion. Associated functionality is provided by the __has_embed preprocessor conditional inclusion macro, which evaluates resource availability and parameter compatibility. The standard defines specific required parameters (limit, prefix, suffix, if_empty) and mandates that the resulting integer sequence, under specific conditions (element width equals CHAR_BIT), should map bit-for-bit to the resource's binary content, enabling static initialization of character arrays with external binary data.
#embed and __has_embed) Summary (C23)#embed directive enables the inclusion of binary resources (data sources accessible from the translation environment) directly into the source code stream.#embed is replaced by a comma-separated list of integer constant expressions corresponding to the data bytes/elements of the resource. If this list is empty, the token sequence replacement is also empty.#embed <h-char-sequence>) and quoted (#embed "q-char-sequence"), with the latter potentially falling back to the bracketed search methodology.pp-tokens before attempting to match the bracketed or quoted forms.__has_embed Conditional Macro:
__STDC_EMBED_FOUND__, __STDC_EMBED_EMPTY__, or __STDC_EMBED_NOT_FOUND__.#if, #elif, #ifdef, etc.).limit parameter. If zero, the resource is considered empty.CHAR_BIT, but can be modified by implementation-defined parameters. The Resource Width must be divisible by the Embed Element Width.unsigned char, or char if non-negative) with the expansion results in data that compares bit-for-bit equal to data obtained via execution-time mechanisms (e.g., fread).limit(constant-expression): An integer constant expression that sets the maximum size of the resource inclusion (expression multiplied by element width) relative to the implementation resource width.prefix(pp-balanced-token-sequence): Inserts the token sequence immediately before the resource data expansion if the resource is non-empty.suffix(pp-balanced-token-sequence): Inserts the token sequence immediately after the resource data expansion if the resource is non-empty.if_empty(pp-balanced-token-sequence): Replaces the entire #embed directive with the provided token sequence if the resource is determined to be empty.