This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Warning about -Wmain for local variables
- From: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- To: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 30 May 2018 16:10:33 +0530
- Subject: Warning about -Wmain for local variables
gcc with -Wmain warns for local variables named main.
int foo()
{
int main = 0;
return main;
}
a.c: In function ‘foo’:
a.c:3:7: warning: ‘main’ is usually a function [-Wmain]
int main = 1;
^~~~
Is this intended ? I assumed that the warning's intent was for
diagnosing variable named main having only external linkage.
Thanks,
Prathamesh