gcc 3.4.4 and the c99 standard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • triphoppa
    New Member
    • Oct 2008
    • 16

    gcc 3.4.4 and the c99 standard

    I'm trying to write some c99 standard code and compile it with gcc 3.4.4 with the net beans IDE. To my surprise there are several features of the new standard that gcc does not support.

    Does anyone know of a way to use variable length arrays using my current compiler?
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    See if you can find a way to use the -c99 flag. If this version of gcc doesn't support it, you'll need to upgrade. Or just use malloc for variable length arrays.

    Comment

    • triphoppa
      New Member
      • Oct 2008
      • 16

      #3
      Originally posted by Laharl
      See if you can find a way to use the -c99 flag. If this version of gcc doesn't support it, you'll need to upgrade. Or just use malloc for variable length arrays.
      First, thx for the reply. What is malloc and can I trigger the -c99 flag with a command line instruction?

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        On the command line, when you use the gcc command, you can give it options, also referred to as flags or switches, by using -. For example, gcc -Wall file.c will compile file.c and link it into an executable called a.out and output any warnings the compiler sees (use of -Wall is good coding practice). In order to change the executable's name, you use the -o filename flag. So gcc -Wall -o exe file.c will create an executable called exe. For the c99 flag, you'd compile with gcc -Wall -o outfile -c99 infile.c. Check the man page for gcc (or Google) for more information, assuming you're on some version of Unix/Linux.

        In Netbeans, there should be a dialog somewhere that lets you change the command used for compilation. I've never used this particular IDE for C/C++, just Java, but I know Visual Studio has it. Look in Project properties or Options, something like that.

        As to malloc, it allows you to declare arrays of whatever length you want, but you have to free them once you're done with them with the free() function. Google for more information.

        Comment

        Working...