Alternate title: News flash: Sometimes things happen by mistake
rbirkby asks
why the SHCOLUMNINFO
structure has 1-byte packing.
“Was the expectation that there would be so many columns
in a details view that the saving would be worthwhile?”
Hardly anything that clever or ingenious. It’s just the consequence of a mistake.
When the SHCOLUMNINFO
structure was added to the
header file in the Windows 2000 timeframe,
it was added with no specific packing directive.
But it turns out that there was a specific packing directive;
it just wasn’t obvious.
Near the top of the shlobj.h
header file was the following:
#include <pshpack1.h> /* Assume byte packing throughout */
(There was of course a matching #include <poppack.h>
at the bottom.)
This set the default packing for the entire header file to byte
packing instead of natural alignment.
By the time this mistake was identified, it was too late. Windows 2000 had already shipped, byte packing and all. And once the code ships, it’s done. You’re stuck with it.
Sorry.
0 comments