use alloca for compatibility with MSVC

This commit is contained in:
Krasimir Angelov
2023-01-26 08:31:44 +01:00
parent ee96bcbb1c
commit b138d0c89b
2 changed files with 8 additions and 1 deletions

View File

@@ -21,6 +21,12 @@
#include <stdio.h>
#endif
#ifdef _MSC_VER
#include <alloca.h>
#define alloca _alloca
#endif
class PGF_INTERNAL_DECL pgf_error : public std::runtime_error {
public:
pgf_error(const char *msg) : std::runtime_error(msg)

View File

@@ -728,7 +728,8 @@ static void add_to_index(ref<PgfConcr> concrete, ref<PgfConcrLin> lin, size_t se
throw pgf_error("Found a lin which uses a category without a lincat");
size_t max_values = 1;
size_t ranges[sym_cat->r.n_terms];
size_t *ranges = (size_t *)
alloca(sym_cat->r.n_terms*sizeof(size_t));
for (size_t i = 0; i < sym_cat->r.n_terms; i++) {
for (size_t j = 0; j < result->vars->len; j++) {
auto var_range = vector_elem(result->vars, j);