From c35fe8b5179cf8022454714d1848abe6cbe2644d Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 9 Oct 2020 16:39:23 +0300 Subject: [PATCH] Make `gb.h` compatible with C++ again for bsnes integration. Fixed #300 --- Core/save_state.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Core/save_state.h b/Core/save_state.h index fcb9135..8e5fc4e 100644 --- a/Core/save_state.h +++ b/Core/save_state.h @@ -5,10 +5,16 @@ #define GB_PADDING(type, old_usage) type old_usage##__do_not_use +#ifdef __cplusplus +/* For bsnes integration. C++ code does not need section information, and throws a fit over certain types such + as anonymous enums inside unions */ +#define GB_SECTION(name, ...) __attribute__ ((aligned (8))) __VA_ARGS__ +#else #define GB_SECTION(name, ...) __attribute__ ((aligned (8))) union {uint8_t name##_section_start; struct {__VA_ARGS__};}; uint8_t name##_section_end[0] #define GB_SECTION_OFFSET(name) (offsetof(GB_gameboy_t, name##_section_start)) #define GB_SECTION_SIZE(name) (offsetof(GB_gameboy_t, name##_section_end) - offsetof(GB_gameboy_t, name##_section_start)) #define GB_GET_SECTION(gb, name) ((void*)&((gb)->name##_section_start)) +#endif #define GB_aligned_double __attribute__ ((aligned (8))) double