compiling nested functions with clang versus gcc

后端 未结 1 1694
日久生厌
日久生厌 2021-01-20 23:50

I have a c file that I can compile with no problem using GCC like below:

gcc foo.c

however using the same file I am receiving error of

相关标签:
1条回答
  • 2021-01-20 23:57

    Functions defined within functions are an extension to the C language, implemented by gcc. This is enabled by default. If you make gcc a Standard C compiler, as with -ansi -pedantic or -std=C99 or similar, it will also complain about nested function definitions:

    x.c: In function ‘main’:
    x.c:8:5: warning: ISO C forbids nested functions [-Wpedantic]
         int nested(void)
         ^
    
    0 讨论(0)
提交回复
热议问题