Skip to content

Conversation

davidebeatrici
Copy link

This is required for MSVC.

@petterreinholdtsen
Copy link
Contributor

The USE_MALLOC name is a bit confusing, as the code of course use mallom even if USE_MALLOC is not defined... What about HAVE_VLA_SUPPORT or something like that instead? Is there some flag in modern C that can be used to detect compilers with such advanced feature available without manually setting a flag?

@davidebeatrici
Copy link
Author

According to https://stackoverflow.com/a/49988810 we can use __STDC_NO_VLA__.

@davidebeatrici
Copy link
Author

Should I do that?

@petterreinholdtsen
Copy link
Contributor

petterreinholdtsen commented Mar 11, 2021 via email

@marler8997
Copy link

marler8997 commented Nov 22, 2023

Here's my own take on a fix: #219

Relevant differences:

  • use alloca instead of malloc
  • use C std version and __STDC_NO_VLA__ to automatically determine VLA support
    • application still has the option to manually define NO_VLA if the automatic detection doesn't work with their toolchain
  • define a stackalloc abstraction so we don't need the ifdefs all over the source

@jmvalin
Copy link
Member

jmvalin commented Mar 26, 2024

Can you give the upgrade1 branch a try. The VLAs should all be replaced with fixes sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants