diff options
Diffstat (limited to 'lib/skin_parser/skin_parser.h')
-rw-r--r-- | lib/skin_parser/skin_parser.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h index fc15aff1be..4f613d219d 100644 --- a/lib/skin_parser/skin_parser.h +++ b/lib/skin_parser/skin_parser.h | |||
@@ -33,8 +33,19 @@ extern "C" | |||
33 | /* Use this type and macro to convert a pointer from the | 33 | /* Use this type and macro to convert a pointer from the |
34 | * skin buffer to a useable pointer */ | 34 | * skin buffer to a useable pointer */ |
35 | typedef long skinoffset_t; | 35 | typedef long skinoffset_t; |
36 | #define SKINOFFSETTOPTR(base, offset) ((offset) < 0 ? NULL : ((void*)&base[offset])) | 36 | /* |
37 | #define PTRTOSKINOFFSET(base, pointer) ((pointer) ? ((void*)pointer-(void*)base) : -1) | 37 | * The statement-expression here is needed to work around a |
38 | * bogus -Waddress warning produced by GCC 12 when this macro | ||
39 | * is used like "if (!SKINOFFSETTOPTR(...))". | ||
40 | * | ||
41 | * Related: | ||
42 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102967 | ||
43 | * https://godbolt.org/z/YEY4Yzdnf | ||
44 | */ | ||
45 | #define SKINOFFSETTOPTR(base, offset) \ | ||
46 | ({ void *__p = ((offset) < 0 ? NULL : ((void*)&base[offset])); __p; }) | ||
47 | #define PTRTOSKINOFFSET(base, pointer) \ | ||
48 | ((pointer) ? ((void*)pointer-(void*)base) : -1) | ||
38 | /* Use this macro when declaring a variable to self-document the code. | 49 | /* Use this macro when declaring a variable to self-document the code. |
39 | * type is the actual type being pointed to (i.e OFFSETTYPE(char*) foo ) | 50 | * type is the actual type being pointed to (i.e OFFSETTYPE(char*) foo ) |
40 | * | 51 | * |