8
请教各位,如何解决 warning: stack protector not protecting local variables: vari...
source link: https://www.v2ex.com/t/818392
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
请教各位,如何解决 warning: stack protector not protecting local variables: variable length buffer
fenglala · 1 小时 3 分钟前 · 69 次点击test.c:
struct Foo{
char a[32]; // 32 and above will produce warning, but 31 and below will not
char d[9]; // 9 and above will produce warning, but 8 and below will not
};
int main()
{
struct Foo foo = {0};
(void)(foo);
return 0;
}
编译命令及输出:
$ arm-eabi-gcc -Wstack-protector -fstack-protector-all -fstack-check -o test test.c
test.c: In function ‘main’:
test.c:6:5: warning: stack protector not protecting local variables: variable length buffer [-Wstack-protector]
int main()
^~~~
实际代码中的结构体类似上文的 Foo ,我不能改,但是 main 我可以改,请问怎么改 main 能解决这个 warning ?
感谢各位!
各位也可以去 https://stackoverflow.com/questions/70133887/how-can-i-fix-warning-stack-protector-not-protecting-local-variables-variable 上回答,我 Google 了一圈都没找到怎么解。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK