GCC 调试/草稿
外观
< GCC 调试
新内容\想法测试页面
关于本书\什么是“GCC 调试”
- 目标
- 详细、易于理解的手册
- 涵盖使用 GCC 进行故障排除
- 使消除错误的过程不那么痛苦\费时
- 目标受众
- 具有编程语言经验的新 GCC 用户
- 风格
- 通用语言(不过于技术性)
- 书籍范围
- gcc
- g++
- gdb
- 其他编译器?
错误和警告页面应包括
- 详细解释错误信息
- GCC 版本(s) 发现于
- 早期版本的错误信息?
- 会导致显示消息的示例代码
- 消除故障信息的修复方法(取决于原因)
底部有备注,错误原因是级别 2 标题下的级别 3 标题,“原因”
Page Title...
==Causes==
===<Possible Error Cause>===
<syntaxhighlight lang="cpp">
// source code producing error
</syntaxhighlight>
''' Solutions'''
What to change...
<syntaxhighlight lang="cpp">
// source code fixing error
</syntaxhighlight>
==Notes==
*Message found in gcc versions x.x.x to x.x.x
<noinclude>{{displaytitle|title=Full Error Message}}</noinclude>
{{BookCat}}
例子
页面标题...
例如,一个函数“foo”从 main 内部调用,它使用一个参数,该参数与任何当前存在的“foo”实现都不完全匹配。
void foo(int x);
void foo(double x);
int main () {
long x = 5000;
foo(x);
...
解决方案
将参数强制转换为匹配声明
int main () {
long x = 5000;
foo((int)x);
创建一个新的、重载版本的被调用函数以匹配参数
void foo(int x);
void foo(double x);
void foo(long x);
int main () {
long x = 5000;
foo(x);
- 查找拼写错误或重复的函数定义/声明
- 在 gcc 版本 4.5.1 中发现该消息
顶部有备注,原因是级别 2 标题而不是级别 3 标题
Page Title...
example of error message
<!-- Make below an info box? -->
'''Found in:''' gcc versions x.x.x to x.x.x
'''Past Versions:''' <!-- If there are any -->
example of error message
'''Found in:''' gcc versions x.x.x to x.x.x
'''See Also:'''
similar error messages?
'''Causes:'''
==<Possible Error Cause>==
<syntaxhighlight lang="cpp">
// source code producing error
</syntaxhighlight>
'''Solutions'''
What to change...
<syntaxhighlight lang="cpp">
// source code fixing error
</syntaxhighlight>
<noinclude>{{displaytitle|title=Full Error Message}}</noinclude>
{{BookCat}}
例子
页面标题...
foo.cpp:23:12 call of overloaded 'foo' is ambiguous
- 发现于:gcc 版本 x.x.x 到 4.5.1
- 原因
例如,一个函数“foo”从 main 内部调用,它使用一个参数,该参数与任何当前存在的“foo”实现都不完全匹配。
void foo(int x);
void foo(double x);
int main () {
long x = 5000;
foo(x);
...
解决方案
将参数强制转换为匹配声明
int main () {
long x = 5000;
foo((int)x);
创建一个新的、重载版本的被调用函数以匹配参数
void foo(int x);
void foo(double x);
void foo(long x);
int main () {
long x = 5000;
foo(x);
- 查找拼写错误或重复的函数定义/声明