https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105863
Bug ID: 105863 Summary: RFE: __attribute__((incbin("file"))) or __builtin_incbin("file") Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hpa at zytor dot com Target Milestone: --- It is a *very* common operation to want to include a preexisting binary object into a compiled project. There are a number of ways to do this, but they all suffer significant shortcomings. The most common ways are to use a preprocessor to convert the input binary object to textual source, or to wrap an object in assembly code and use .incbin. The former is *extremely* inefficient, the latter has a number of pitfalls, including the one described in bug 66871, the need for platform-specific coding, sizeof() not being functional, etc. I would like to suggest a variable attribute __attribute__((incbin("file"))) which statically initializes a variable to the contents of the given binary file, or a __builtin_incbin("file") which would expand to an initializer; the end result would look either like: char foobar[] __attribute__((incbin("foobar.bin"))); char foobar[] = __builtin_incbin("foobar.bin");