[C++]
[StructLayout(LayoutKind::Explicit, Size=16, CharSet=CharSet::Ansi)]
__value class MySystemTime {
public:
[FieldOffset(0)] short int wYear;
[FieldOffset(2)] short int wMonth;
[FieldOffset(4)] short int wDayOfWeek;
[FieldOffset(6)] short int wDay;
[FieldOffset(8)] short int wHour;
[FieldOffset(10)] short int wMinute;
[FieldOffset(12)] short int wSecond;
[FieldOffset(14)] short int wMilliseconds;
};
Am I imagining this, or are the elements in square brackets not consistent with C++ syntax?
Why go through the trouble of doing all of this when C++ provides adequate tools to specify struct layout within the standard definition of the language (and perhaps with the typically supported #pragma pack() ). Doesn't the compatibility designed into the language guarantee that you can define in C++ any struct you can define in C? I understand the need to be able to explicitly describe the layout of a C struct in other languages, but it seems like it would not be necessary with C++ which provides
extern "C" { }