LLVM Clang 19 Lands Support For C23's #embed
Merged today to LLVM Clang 19 Git is support for the #embed resource inclusion mechanism that is an approved C23 feature. This also makes Clang the first for supporting this pre-processor embed feature.
C23's #embed pre-processor directive makes it easy to include binary data within an executable. With C23 #embed the developer can include the contents of an external binary file at compile-time without relying on any external approaches or resorting to loading the external binary file(s) at run-time.
More details on the C23 #embed feature can be found via the open-std.org whitepaper on the feature. The abstract is as follows:
Since last year has been this pull request making all the necessary changes to support the #embed pre-processor for both C and C++. After months of work, that code was merged this morning and now makes LLVM Clang the first of the major open-source compilers supporting this directive.
The current C23 language status with the Clang compiler can be found via this status page.
C23's #embed pre-processor directive makes it easy to include binary data within an executable. With C23 #embed the developer can include the contents of an external binary file at compile-time without relying on any external approaches or resorting to loading the external binary file(s) at run-time.
More details on the C23 #embed feature can be found via the open-std.org whitepaper on the feature. The abstract is as follows:
"Pulling binary data into a program often involves external tools and build system coordination. Many programs need binary data such as images, encoded text, icons and other data in a specific format. Current state of the art for working with such static data in C includes creating files which contain solely string literals, directly invoking the linker to create data blobs to access through carefully named extern variables, or generating large brace-delimited lists of integers to place into arrays. As binary data has grown larger, these approaches have begun to have drawbacks and issues scaling. From parsing 5 megabytes worth of integer literal expressions into AST nodes to arbitrary string literal length limits in compilers, portably putting binary data in a C program has become an arduous task that taxes build infrastructure and compilation memory and time. This proposal provides a flexible preprocessor directive for making this data available to the user in a straightforward manner."
Since last year has been this pull request making all the necessary changes to support the #embed pre-processor for both C and C++. After months of work, that code was merged this morning and now makes LLVM Clang the first of the major open-source compilers supporting this directive.
The current C23 language status with the Clang compiler can be found via this status page.
6 Comments