Top-Down Structs

AgentOrange AgentOrange_member at pathlink.com
Fri Mar 10 12:29:25 PST 2006


In article <duropj$o85$1 at digitaldaemon.com>, Bob W says...
>
>
>After using some Win32 declarations, wich are
>obviously not part of "std.c.windows.windows",
>I have noticed that a resulting program crashes with
>
>    "Error: Win32 Exception" .
>
>This happens if the main structure ("INPUT_RECORD")
>is declared before the other structures contained in
>the main structure. The problem will not arise if
>sub-structs [B] are declared earlier than the main
>struct [A].
>
>Before that incident I was convinced that the
>D compiler would handle "top-down" declarations
>correctly.
>
>
>
>----- "Problematic" declaration sequence: -----
>
>
>// INPUT_RECORD [A]
>
>struct INPUT_RECORD {
>  WORD EventType;
>  union {
>    KEY_EVENT_RECORD KeyEvent;
>    MOUSE_EVENT_RECORD MouseEvent;
>    WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
>    MENU_EVENT_RECORD MenuEvent;
>    FOCUS_EVENT_RECORD FocusEvent;
>} }
>
>
>// Structs contained in INPUT_RECORD [B]
>
>struct KEY_EVENT_RECORD {
>  BOOL bKeyDown;
>  WORD wRepeatCount;
>  WORD wVirtualKeyCode;
>  WORD wVirtualScanCode;
>  union  {  WCHAR UnicodeChar;  CHAR AsciiChar;  }
>  DWORD dwControlKeyState;
>}
>
>struct MOUSE_EVENT_RECORD {
>  COORD dwMousePosition;
>  DWORD dwButtonState;
>  DWORD dwControlKeyState;
>  DWORD dwEventFlags;
>}
>
>struct WINDOW_BUFFER_SIZE_RECORD { COORD dwSize; }
>struct MENU_EVENT_RECORD { UINT dwCommandId; }
>struct FOCUS_EVENT_RECORD { BOOL bSetFocus; }
>
>
>

align(1) ?





More information about the Digitalmars-d-bugs mailing list