c++ - 理解和解析来自 gcc 的警告

标签 c++ gcc emacs makefile

当通过 M-x compile(运行文件夹的 Makefile)从 Emacs 编译 .cpp 文件时,我在编译缓冲区中看到以下内容(在编译模式下显示):

In file included from: /path/to/file1:60,
  from /path/to/file2.h:15,
  from /path/to/file3.cpp:16: 

/path/to/file4.h:28:2: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.

  • 除了实际的警告消息之外,我应该如何理解此跟踪?即哪个文件产生了警告? (file1file2file3file4)?
  • 另外,为什么file2行后面有一个逗号,file3行后面有一个冒号,file4行后面有两个数字用两个冒号分隔?

我正在使用 Emacs 24.2.1,带有 gcc-4.4.5-x86_64

最佳答案

实际触发警告的构造(在本例中为 #warning 预处理器指令)在 file4 中。上面的内容是 #include 堆栈的踪迹,最内层但第一个:在这种情况下,file3 包含 file2,它包含 file1,其中包含 file4

当 gcc 知道触发诊断的构造的列号时,它会打印文件名、冒号、行号、另一个冒号和列号,如您在 file4 线。第一个数字是行号 (28),第二个数字是列号(在这种情况下,您会发现 #warning# 在第 2 列).当 gcc 不知道 列号时,它只打印文件名、冒号和行号。 #include 堆栈就是这种情况,因为它不会记录 #include 指令的确切列。 Emacs 的编译模式理解如何解析这两种语法:您会发现,如果您使用 C-x ` 翻阅诊断,当有可用的列号时,Emacs 会将光标放在适当的列。

这些报告末尾的冒号和逗号只是为了符合英文标点符号惯例;它们没有任何意义。

关于c++ - 理解和解析来自 gcc 的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12806817/

相关文章:

c++ - 让 ostream 打开

c++ - 空 vector 是其结构的大小吗?

c++ - 当我尝试删除 [] 数组时,为什么我的程序会抛出 SIGABRT?

c - 编译C文件时出现Unsupported x86-64 instruction set错误

python - 在 Flycheck 中使用正确的 virtualenv 和 flake8 配置

emacs - 如何在 tuareg-mode emacs 中指定注释文件的自定义路径?

emacs - 有这么多括号,你如何有效地输入 lisp?

c++ - 如何将基类仅链接到其顶级模板化父级?

c++ - 字符串插入排序

java - 如何修复 fatal error jvmti.h No such file or directory compilation terminated c code ubuntu?