Sujet : Re: Hex string literals (was Re: C23 thoughts and opinions)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.cDate : 18. Jun 2024, 09:12:15
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4rfgv$18eq9$5@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Pan/0.158 (Avdiivka; )
On Mon, 17 Jun 2024 18:57:09 -0700, Keith Thompson wrote:
You could use some kind of type punning. For example, this is currently
legal:
union {
unsigned char buf[4];
uint32_t n;
} obj = {
.buf = { 0x01, 0x02, 0x03, 0x04 }
};
The { 0x01, 0x02, 0x03, 0x04 } could be replaced with 0x"01020304".
In Open Source, the definition of “source” is (to the effect of) “the
preferred representation of the program for doing development with”.
The implication to me is, if the C source form has to be cryptic and
error-prone and basically hard to work with, then I would back up one step
and use some other form for that part of the source, that would be
translated to C source as part of the build process and linked against the
rest of the code. The generated C source would not be part of the repo
commit history, but the input used to generate it (along with any custom
build tool setup/programming) would.