Skip to content

Commit cdf5643

Browse files
fix MSVC compilation
1 parent 27749ed commit cdf5643

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Python/typecache.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414
#include "pycore_pyatomic_ft_wrappers.h"
1515
#include "pycore_typeobject.h" // _PyStaticType_GetState()
1616

17-
static struct {
17+
18+
// This is a union because MSVC doesn't support flexible array member in
19+
// the middle of a struct and we use a char array to reserve space for the
20+
// actual hashtable entries of the empty cache.
21+
static union {
1822
struct type_cache cache;
19-
struct type_cache_entry entries[_Py_TYPECACHE_MINSIZE];
23+
char storage[sizeof(struct type_cache)
24+
+ _Py_TYPECACHE_MINSIZE * sizeof(struct type_cache_entry)];
2025
} empty_cache_storage = {
2126
.cache = {
2227
.mask = _Py_TYPECACHE_MINSIZE - 1,

0 commit comments

Comments
 (0)