Questionable definition of INPUT_RECORD in struct.inc lazarus / 67-Windows ---------------------------------------------------------------------- 440bx · 2019-04-10 03:09 Hello, in struct.inc, INPUT_RECORD is defined as follows:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i      INPUT_RECORD = record          EventType: Word;          Reserved: Word;          Event : record case longint of                 0 : ( KeyEvent : KEY_EVENT_RECORD );                 1 : ( MouseEvent : MOUSE_EVENT_RECORD );                 2 : ( WindowBufferSizeEvent : WINDOW_BUFFER_SIZE_RECORD );                 3 : ( MenuEvent : MENU_EVENT_RECORD );                 4 : ( FocusEvent : FOCUS_EVENT_RECORD );       end;      end;                                           Note the presence of "Reserved : Word" after EventType. The MSDN defines INPUT_RECORD as follows:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i typedef 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;  } Event;} INPUT_RECORD; Note the absence of a "Reserved" field after EventType. The FPC definition ends up working because of alignment but, there is no "reserved" field in INPUT_RECORD. ---------------------------------------------------------------------- ASerge · 2019-04-10 04:52 Quote from: 440bx on April 10, 2019, 05:09:10 amThe FPC definition ends up working because of alignment but, there is no "reserved" field in INPUT_RECORD. Compatible with Delphi? And it is interesting that in recent versions in Delphi is clearly removed alignment to justify this field: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ALIGN 1}  PInputRecord = ^TInputRecord;  {$EXTERNALSYM _INPUT_RECORD}  _INPUT_RECORD = record    EventType: Word;    Reserved: Word;...  INPUT_RECORD = _INPUT_RECORD;{$ALIGN ON} ---------------------------------------------------------------------- engkin · 2019-04-10 04:59 Unit JwaWinCon: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //fpc\3.0.4\source\packages\winunits-jedi\src\jwawincon.pas:  _INPUT_RECORD = record    EventType: WORD;    case Integer of      0: (KeyEvent: KEY_EVENT_RECORD);      1: (MouseEvent: MOUSE_EVENT_RECORD);      2: (WindowBufferSizeEvent: WINDOW_BUFFER_SIZE_RECORD);      3: (MenuEvent: MENU_EVENT_RECORD);    4: (FocusEvent: FOCUS_EVENT_RECORD);  end; ---------------------------------------------------------------------- marcov · 2019-04-10 08:18 Afaik the windows headers started out as packed records. IOW only manual alignment ---------------------------------------------------------------------- 440bx · 2019-04-10 11:21 Quote from: marcov on April 10, 2019, 10:18:37 amAfaik the windows headers started out as packed records. IOW only manual alignment It's a bit disconcerting to see it defined one way in MSDN and a different way in FPC.    I figured I'd point it out because you've made it clear that _in general_ you follow MSDN whenever possible.  In this case it's definitely possible to follow MSDN and unless a programmer is accessing that alignment field, there shouldn't be any compatibility issues in removing it. Someone might think that field is actually used for something (like the reserved field passed to a dll entry point) when it really isn't, just alignment/filler.