内部に共用体を持つ C 構造体を移植しようとしています。のデフォルト構造でWinapi.Winsock2.pas
は、レコード内のいくつかのフィールドが欠落しています。しかし、これは正しい方法ですか?ありがとう。
typedef struct _WSACOMPLETION {
WSACOMPLETIONTYPE Type;
union {
struct {
HWND hWnd;
UINT uMsg;
WPARAM context;
} WindowMessage;
struct {
LPWSAOVERLAPPED lpOverlapped;
} Event;
struct {
LPWSAOVERLAPPED lpOverlapped;
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpfnCompletionProc;
} Apc;
struct {
LPWSAOVERLAPPED lpOverlapped;
HANDLE hPort;
ULONG_PTR Key;
} Port;
} Parameters;
} WSACOMPLETION;
_WSACOMPLETION = record
&Type: WSACOMPLETIONTYPE;
case Parameters: Integer of
0: (hWnd: HWND; uMsg: UINT; context: WPARAM); // WindowMessage
1: (lpOverlapped: LPWSAOVERLAPPED); // Event
2: (lpOverlapped: LPWSAOVERLAPPED; lpfnCompletionProc: LPWSAOVERLAPPED_COMPLETION_ROUTINE); // Apc
3: (lpOverlapped: LPWSAOVERLAPPED; hPort: HANDLE; Key: ULONG_PTR); //Port
end;
コンパイラは文句を言いますError: E2004 Identifier redeclared: 'lpOverlapped'
更新 2:
いろいろ考えた結果、これにたどり着きました。
_WSACOMPLETION = record
&Type: WSACOMPLETIONTYPE;
case Parameters: Integer of
0: (WindowMessage: record
hWnd: HWND;
uMsg: UINT;
context: WPARAM;
end);
1: (Event: record
lpOverlapped: LPWSAOVERLAPPED;
end);
2: (Apc: record
lpOverlapped: LPWSAOVERLAPPED;
lpfnCompletionProc: LPWSAOVERLAPPED_COMPLETION_ROUTINE
end);
3: (Port: record
lpOverlapped: LPWSAOVERLAPPED;
hPort: HANDLE;
Key: ULONG_PTR;
end)
end;