Can the C main() function be static?

前端 未结 5 814
北荒
北荒 2021-01-01 17:00

Can the main() function be declared static in a C program? If so then what is the use of it?

Is it possible if I use assembly code and call

5条回答
  •  春和景丽
    2021-01-01 17:16

    C has two meanings for 'static'...

    static for a local variable means it can be used globally. static for a global variable means is can only be used in the current file.

    static for functions has the exact same impact as denoting a global variable as static ... the static function IS ONLY VISIBLE IN THE CURRENT FILE ...

    Thus main can NEVER be static, because it would not be able to serve as the primary entry point for the program.

提交回复
热议问题