vendredi 2 septembre 2016

Is there a fully Standard compliant way to make the compiler paste the exact (binary) contents of a file in a source file?

I would like to provide the ease of use of Qt's Resource system (basically an xml containing a list of files, that is precompiled into a C++ source file containing a bunch of char arrays of the binary byte content of these files, which is compiled into the binary), in pure C++.

So I wonder, is the first and pretty much only requirement, even at all possible? Can I compile a binary file into an object file? I know it's not simply possible to #include another file in a C++11 raw string literal, but maybe there is a way around this. I would like to ditch the precompile step. Is there a way?

In the worst case, maybe a linker script and some voodoo in the code to access these bytes can make this functional, but I don't know if that's any better than the precompile step (which is certainly a lot more transparent...).

Aucun commentaire:

Enregistrer un commentaire