# include <stdio.h>
# include <stdlib.h>
int myvariable_NOT_caught_by_Wall;
int main ( int argc, char *argv[] )
{
int myvariable_caught_by_Wall;
return 0;
}
通过 gcc some_program.c -wall no no警告未使用的全球变量?
有没有办法实现这一目标?我在SLES_11.4
通过GCC通过gcc some_program.c -wall wall no dustand to nowing to no Pused Global变量时,GCC是否正常?
?
是。
编译器在编译时不知道不使用全局变量。
想象另一个.c文件:
extern int myvariable_NOT_caught_by_Wall;
void foo()
{
if (myvariable_NOT_caught_by_Wall == 0 )
{
dothis();
}
else
{
dothat();
}
}
感谢那个说 static 的家伙,它可以执行我专门寻找的东西。如果不需要-O2 -Wall
,我不想使用其他编译选项。
我的目标是简单地完成编写一个 .c文件,我需要快速编写它,以执行特定的数据处理任务,在此不值得做额外的写作使用malloc()
和calloc()
和free()
代码,当我可以简单地在Main((之外进行全局(例如double myarray[5][2][10][3600][9000][2];
如果您想知道,它是为了将一些信号数据存储到文本文件中,我可以为每个外观
提供多达9000个示例或更多的示例[#levitation_angles] [偏振h或v] [#frequencies] [#az_angles] [#samples] [i或q]
# include <stdio.h>
# include <stdlib.h>
static int myvariable_NOW_caught_by_Wall; /* -Wall catches this when static */
int main ( int argc, char *argv[] )
{
int myvariable_caught_by_Wall;
return 0;
}