gpt4 book ai didi

c - gcc -g0 并且没有 -g 选项

转载 作者:IT王子 更新时间:2023-10-29 00:54:07 25 4
gpt4 key购买 nike

在 gcc 中不带 -g 选项编译和带 -g0 选项编译有什么区别?在 gcc 中提供 -g0 选项背后有什么具体原因吗?我尝试编译并在 GDB 中的两种情况下都发现了“没有调试符号”消息。

最佳答案

如果你去 GCC manual ,你会发现它说:

-glevel

Request debugging information and also use level to specify how much information. The default level is 2.

Level 0 produces no debug information at all. Thus, -g0 negates -g.

因此,如果您需要调试信息,请不要使用 -g0。如果您确实需要调试信息,请记住在创建目标文件 (-c) 和链接程序时都使用 -g 选项。

完全不使用 -g 进行编译与使用 -g0 进行编译是等效的,并且在生成的二进制文件中没有调试信息 — 正如您通过实验发现的那样。

关于c - gcc -g0 并且没有 -g 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36708484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com