-1
\$\begingroup\$

I'm making a C library for the embedded system community.

I was wondering: In your experiences, do most people use compilers that support C99 VLA?

\$\endgroup\$
10
  • \$\begingroup\$ Can you give a list of compilers that support C99 VLA then? What it is useful for? \$\endgroup\$ – Justme Nov 28 '20 at 20:46
  • 4
    \$\begingroup\$ Yes, 32-bit systems will support this for the most part. Particularly the common ARM compilers (GCC, IAR, Keil, Clang), though YMMV for proprietary architectures. Unbounded stack allocation tends to be frowned upon though. \$\endgroup\$ – doynax Nov 28 '20 at 20:46
  • 2
    \$\begingroup\$ If you want to support as many compilers as possible, use as few features of a certain standard as possible, or the oldest standard possible (but not K&R). Otherwise you will have to validate each compiler your users like to use. \$\endgroup\$ – the busybee Nov 29 '20 at 16:05
  • 1
    \$\begingroup\$ @gberth if you want to know if people use compilers that supports some obscure feature X, how would they know if it supports it, unless you provide a list of compilers that support obscure feature X, so people can answer based on which compiler they use and they don't have to go search or test if obscure feature X is supported or not. What would you use VLAs for, in an embedded library? What do you consider embedded, a 64-bit ARM or 8-bit 8051, or something between? \$\endgroup\$ – Justme Nov 30 '20 at 16:11
  • 1
    \$\begingroup\$ So you are writing a lib for embedded and you consider VLA but not MISRA-C? The former is kind of irrelevant, the latter is industry standard and bans VLA. \$\endgroup\$ – Lundin Dec 2 '20 at 7:52
2
\$\begingroup\$

C99 compilers have to support VLA, unlike C11/C17 ones that may optionally define __STDC_NO_VLA__ if they for some strange reason don't support it. So you question is a bit confused, maybe you are asking this:

Q: Do most microcontroller compilers support C99? A: Yes, all of them do unless they are legacy stuff kept for maintaining older systems. Many companies are still stuck with C90 coding standards however, running compilers in C90 mode.

Q: Do all C99 compilers support VLA?
A: Yes.

Q: Are there are C11/C17 compilers, embedded or otherwise, that doesn't support VLA?
A: I have yet to find one. All the mainstream compilers, embedded or hosted, support it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.