|
 |
"Darren New" <dne### [at] san rr com> wrote in message
news:4ae0c668$1@news.povray.org...
> Captain Jack wrote:
>> Wouldn't bit fields do what you're describing?
>
> Only if they're all aligned to byte boundaries, and you know what order
> the fields are in. I.e., yes, but in no way portably. There's no way to
> portably (for example) lay a C structure for an IP datagram header onto
> the header and just use it.
That's true... I know the specification calls for packing the bytes as
tightly as possible, but there's no standard spec for alignment.
I used to use Borland's Turbo C (v2, IIRC) way back when on DOS machines. I
remember that it had custom pre-processor directives for controlling byte
and word alignment, but I'm sure those weren't in any way standard.
I also used to make use of its "asm" keyword which would let me insert x86
assembler code into the middle of my C code, and I'd often use that to
squeeze some extra bits out of my memory usage. Contrast that with my
current job, where we use .NET, and I don't even keep track of what I've
allocated and deallocated, or how much I've used. I seem to have grown fat
and lazy on the backs of the developers at Redmond. 8D
> I don't think C handles *any* of that. About the closest it comes is
> volatile (sort of) and undefined behavior that *often* does what you'd
> expect when using addresses, unless your memory model is too far different
> from C's.
But that was what's so great about pure C... nothing lets you shoot yourself
in the foot with confidence the way C does. <g>
Post a reply to this message
|
 |