Hello, I have the following problem:
when declaring hex data in C, you typically do something like:
const char[] = {0xde, 0xad, 0xbe, 0xef, 0x01, 0x02, 0x03, 0x04 ... };
This is quite verbose and makes the source hard to read.
An alternative is something like
const char[] = "deadbeef010203 04";
but this doubles the storage requirements since each nybble is
converted to an ASCII char.
Some old assemblers have HEX directives for declaring large chunks of
raw data. My question is: is there any way to do this in C? Excessive
preprocessor acrobatics are OK as long as they work in gcc...
The hex data I have is several thousand strings like:
CRC(b746de6d) SHA1(ea69f87f84 ded1f0a66457af2 4cbc692e5ff67e3 )
Really, I just want a preprocessor macro that does a trivial regex like
s/([a-fA-F0-9][a-fA-F0-9])/0x\1,/ is that possible?
when declaring hex data in C, you typically do something like:
const char[] = {0xde, 0xad, 0xbe, 0xef, 0x01, 0x02, 0x03, 0x04 ... };
This is quite verbose and makes the source hard to read.
An alternative is something like
const char[] = "deadbeef010203 04";
but this doubles the storage requirements since each nybble is
converted to an ASCII char.
Some old assemblers have HEX directives for declaring large chunks of
raw data. My question is: is there any way to do this in C? Excessive
preprocessor acrobatics are OK as long as they work in gcc...
The hex data I have is several thousand strings like:
CRC(b746de6d) SHA1(ea69f87f84 ded1f0a66457af2 4cbc692e5ff67e3 )
Really, I just want a preprocessor macro that does a trivial regex like
s/([a-fA-F0-9][a-fA-F0-9])/0x\1,/ is that possible?
Comment