How enable c99 mode in gcc with terminal

后端 未结 3 960
北海茫月
北海茫月 2021-02-07 22:04

I want to activate c99 mode in gcc compiler to i read in other post in this forum that -std should be equal to -std=c99 but i don\'t know how to set it

3条回答
  •  忘掉有多难
    2021-02-07 22:35

    Based on the comments under another answer, perhaps you are using the implicit make rules and don't have a Makefile. If this, then you are just runing make tst to generate tst binary from tst.c. In that case you can specify the flags by setting the environment variable CFLAGS. You can set it for the current shell, or add it to your ~/.bashrc to have it always, with this:

    export CFLAGS='-Wall -Wextra -std=c99'
    

    Or specifying it just for the single command:

    CFLAGS='-Wall -Wextra -std=c99' make tst
    

    (Note: I added warning flags too, you should really use them, they will detect a lot of potential bugs or just bad code you should write differently.)

提交回复
热议问题