Using the word main as an identifier

Can main be used as an identifier?

If so, what could be the scenarios?

+7
source share
3 answers

Why not, if you are not using it the way main() , that is, as a function.

 /* Error -- > */ int main() { return 1; } // Redefinition of main() struct main{}; // ok int main = 0 ; // error int main(void) { int main=0; // But has to be local. goto main; printf("Hello"); main: printf("World"); } 

Remember main is NOT keyword. But I guess we haven't run out of words, so why use it?

+5
source

Technically? As the name of a static or auto variable inside any function, or as a variable of type static in any file other than the file containing main() . It can also work as a struct or union tag or as a typedef anywhere, but a file containing main() .

Practically? This is a good way to confuse yourself when you return to the program after a year and wonder what the idiot thought was a good idea. :)

+4
source

Ok, here's the question: $ 64,000: why do you want to do this? Perhaps you plan to enter the tangled C contest? Some kind of unique approach to writing a question? A test test for a similar lint program? This is not what you would like to do in a real program.

+2
source

All Articles