Why does SHCOLUMNINFO have unusually tight packing?
News flash: Sometimes things happen by mistake
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
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
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,
You’re stuck with it.