Skip to content

Commit

Permalink
msvc: fix build: typeof needs to be __typeof__.
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Sep 30, 2024
1 parent 3f68208 commit 899875b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
# define strcasecmp _stricmp
#endif

#ifdef _MSC_VER
# define CEMU_TYPEOF __typeof__
#else
# define CEMU_TYPEOF typeof
#endif

#ifdef __EMSCRIPTEN__
# include <emscripten.h>
#else
Expand Down
5 changes: 4 additions & 1 deletion core/usb/physical.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@

#define NODE_EMPTY(head) \
((head)->next == (head))

#define NODE_ITEM(type, item) \
((type *)((uint8_t *)(item) - \
offsetof(type, node)))

#define NODE_FIRST(type, head) \
(NODE_EMPTY(head) ? NULL : NODE_ITEM(type, (head)->next))

#define NODE_FOREACH(current, head) \
for (node_t *next = (head)->next; \
((current) = next != (head) \
? NODE_ITEM(typeof(*(current)), next) \
? NODE_ITEM(CEMU_TYPEOF(*(current)), next) \
: NULL), next = next->next, (current); )

#define UPDATE_STATUS_CHANGE(pointer, field, value) do { \
Expand Down

0 comments on commit 899875b

Please sign in to comment.