summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorstijn <stijn@ignitron.net>2022-06-23 16:02:59 +0200
committerDamien George <damien@micropython.org>2022-07-18 23:25:12 +1000
commit1f16d682daa822a209127b432097113cfcf308d9 (patch)
tree7ad287aae1d418e6fd6c6470ecab4a390065196e /py
parentc4adeb2e0873c32a14e49a62023cd99ccdf3d78f (diff)
py/misc: Fix msvc compilation with compressed error messages.
Diffstat (limited to 'py')
-rw-r--r--py/misc.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/py/misc.h b/py/misc.h
index b7b6146ab..e642598c5 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -293,15 +293,16 @@ typedef union _mp_float_union_t {
// Force usage of the MP_ERROR_TEXT macro by requiring an opaque type.
typedef struct {
- #ifdef __clang__
- // Fix "error: empty struct has size 0 in C, size 1 in C++".
+ #if defined(__clang__) || defined(_MSC_VER)
+ // Fix "error: empty struct has size 0 in C, size 1 in C++", and the msvc counterpart
+ // "C requires that a struct or union have at least one member"
char dummy;
#endif
} *mp_rom_error_text_t;
#include <string.h>
-inline __attribute__((always_inline)) const char *MP_COMPRESSED_ROM_TEXT(const char *msg) {
+inline MP_ALWAYSINLINE const char *MP_COMPRESSED_ROM_TEXT(const char *msg) {
// "genhdr/compressed.data.h" contains an invocation of the MP_MATCH_COMPRESSED macro for each compressed string.
// The giant if(strcmp) tree is optimized by the compiler, which turns this into a direct return of the compressed data.
#define MP_MATCH_COMPRESSED(a, b) if (strcmp(msg, a) == 0) { return b; } else