From 3354560c7b5bf8363779aed4cc7d5fc5077afa56 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 26 Jan 2025 12:59:19 +0100 Subject: [PATCH] Avoid Py_ARRAY_LENGTH() Replace Py_ARRAY_LENGTH(array) with sizeof(array)/sizeof(array[0]). Py_ARRAY_LENGTH() fails with C++ on Python 3.9 on macOS. --- pythoncapi_compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index 8cf63f5..4d28846 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -2092,7 +2092,7 @@ PyConfig_Get(const char *name) const PyConfigSpec *spec; int found = 0; - for (size_t i=0; i < Py_ARRAY_LENGTH(config_spec); i++) { + for (size_t i=0; i < sizeof(config_spec) / sizeof(config_spec[0]); i++) { spec = &config_spec[i]; if (strcmp(spec->name, name) == 0) { found = 1;