Liste des Groupes | Revenir à cl c |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:You need the Baby X resource compiler.David Brown <david.brown@hesbynett.no> writes:On 26/05/2024 00:58, Keith Thompson wrote:>A typical use case for me would be to build a binary fileIt knows because the compiler writers are actually quite smart. The C>
standards may describe the translation process in a series of distinct
and independent phases, but that's not how it is done in practice.
The key point is that the compiler knows how the sequence of integers
is going to be used before it gets that far in the preprocessing.
>
I'd expect implementations to have extremely fast implementations for
initialising arrays of character types, and probably also for other
arrays of scaler types. More complicated examples - such as
parameters in a macro or function call - would probably use a
fall-back of generating naïve lists of integer constants.
My problem is not just with how the compiler can figure out when it can
optimize, but how programmers are supposed to understand whatever rules
it uses. Can I rely on the optimization being performed if I use a
typedef for unsigned char, or if I use an enumeration type whose
underlying type is unsigned char, or if I have initialization elements
befor and after the #embed directive?
with a bespoke application. I would expect the #embed of that
file to _maintain the binary layout in memory exactly the
same as in the file_. It would be the #embed user's
responsibilty to ensure that the binary file would be identical
to the binary data expected by the declaration of the data structure
being embedded.
E.g. if the embedded file contained an array of some structure,
the binary format of the embedded file must match the binary format
that would be expected by the compiler (field sizes, alignment etc)
for an array of said structure.
The spec does say that the data in memory must match the data in the
file. So it seems that the preprocessor can simply add a private
attribute (e.g. just pass the #embed to the compiler a la #line or #file)
and the compiler will tag the symbol table entry for the symbol associated
with the #embed and the code generator can just open the file and
copy the data byte-for-byte to the object file.
Les messages affichés proviennent d'usenet.