Skip to content

Commit

Permalink
Windows: Assert that struct has the correct size
Browse files Browse the repository at this point in the history
ULONG and bitfields are not well defined and behave differently on
different compilers. Thus make sure the struct
hid_pp_link_collection_node_ has the correct size.
  • Loading branch information
cmorty committed Nov 17, 2023
1 parent b5e803d commit b57d3b0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions windows/hidapi_descriptor_reconstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <windows.h>

#include "hidapi_hidsdi.h"
#include <assert.h>

#define NUM_OF_HIDP_REPORT_TYPES 3

Expand Down Expand Up @@ -125,6 +126,9 @@ typedef struct hid_pp_link_collection_node_ {
// Same as the public API structure HIDP_LINK_COLLECTION_NODE, but without PVOID UserContext at the end
} hid_pp_link_collection_node, *phid_pp_link_collection_node;

static_assert(sizeof(struct hid_pp_link_collection_node_) == 16,
"Size of struct hid_pp_link_collection_node_ not as expected. This might break binary compatibility");

typedef struct hidp_unknown_token_ {
UCHAR Token; /* Specifies the one-byte prefix of a global item. */
UCHAR Reserved[3];
Expand Down

0 comments on commit b57d3b0

Please sign in to comment.