Variable-length size for an array declaration.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • axas
    New Member
    • Jul 2006
    • 32

    Variable-length size for an array declaration.

    Why on Windows we can' t declare an array with a variable for array's size?

    e.g.

    void func(int size)
    {
    int array[size];
    }

    On Linux systems we can do it.
    Even the GCC compiler for Windows don't support it.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It's not Windows

    This is a C99 feature, I guess all the compilers you are using on Windows are C89 which is still very common.

    I would have thought you could make the gcc windows compiler use the C99 standard.

    Comment

    • tyreld
      New Member
      • Sep 2006
      • 144

      #3
      Have you tried invoking gcc with C99 flag?

      "gcc -std=c99"

      Comment

      Working...