[Solved] why the program with static main() type shows error?


In C, static is the primary way of “hiding” implementation details. Marking a function or a variable static in C means restricting its visibility to the translation unit in which it is defined. Essentially, only functions inside the same C file can refer to them. Functions from other files or libraries have no way of accessing them.

Since function main needs to be accessed from your environment’s start-up code (a piece of code that “bootstraps” your program execution) hiding it renders your program non-linkable: compiler tries to find main, but it is hidden, so the linker issues an error.

solved why the program with static main() type shows error?