py/misc: Fix msvc compilation with compressed error messages.
This commit is contained in:
parent
c4adeb2e08
commit
1f16d682da
|
@ -293,15 +293,16 @@ typedef union _mp_float_union_t {
|
||||||
|
|
||||||
// Force usage of the MP_ERROR_TEXT macro by requiring an opaque type.
|
// Force usage of the MP_ERROR_TEXT macro by requiring an opaque type.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#ifdef __clang__
|
#if defined(__clang__) || defined(_MSC_VER)
|
||||||
// Fix "error: empty struct has size 0 in C, size 1 in C++".
|
// 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;
|
char dummy;
|
||||||
#endif
|
#endif
|
||||||
} *mp_rom_error_text_t;
|
} *mp_rom_error_text_t;
|
||||||
|
|
||||||
#include <string.h>
|
#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.
|
// "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.
|
// 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
|
#define MP_MATCH_COMPRESSED(a, b) if (strcmp(msg, a) == 0) { return b; } else
|
||||||
|
|
Loading…
Reference in New Issue