extern declaration and function definition both in the same file

前端 未结 5 1805
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 09:08

I was just browsing through gcc source files. In gcc.c, I found something like

extern int main (int, char **);

int
main (int argc, cha         


        
5条回答
  •  盖世英雄少女心
    2021-02-20 09:49

    The definition of the main function:

    int main(int argc, char **argv) { ... }
    

    is already a declaration is the prototyped syntax of the function main with external linkage. This means a prototyped declaration with extern just before the main definition is redundant.

提交回复
热议问题