g++ -E option output

大兔子大兔子 提交于 2019-12-07 06:35:15

问题


Using this option I receive files after preprocessing. There are many lines like:

# 91 "/usr/include/stdint.h" 3 4

What do the numbers mean? First I thought that #91 is the number of line where file is included, but that is not it. And about 3 4 I have no idea at all.


回答1:


According to the official documentation, the line is of the format:

# linenum filename flags

The linenum specifies that the following line originated in filename at that line number. Then there are four flags:

  • 1 - Start of a new file
  • 2 - Returning to a file
  • 3 - System header file
  • 4 - Treat as being wrapped in extern "C"

So let's interpret your linemarker:

# 91 "/usr/include/stdint.h" 3 4

The following line originated from line 91 of /usr/include/stdint.h. It is a system header file and should be treated as wrapped in extern "C".




回答2:


These are called "line markers". From the documentation:

Source file name and line number information is conveyed by lines of the form

# linenum filename flags

These are called linemarkers. They are inserted as needed into the output (but never within a string or character constant). They mean that the following line originated in file filename at line linenum. filename will never contain any non-printing characters; they are replaced with octal escape sequences.

After the file name comes zero or more flags, which are ‘1’, ‘2’, ‘3’, or ‘4’. If there are multiple flags, spaces separate them. Here is what the flags mean:

  • ‘1’ - This indicates the start of a new file.
  • ‘2’ - This indicates returning to a file (after having included another file).
  • ‘3’ - This indicates that the following text comes from a system header file, so certain warnings should be suppressed.
  • ‘4’ - This indicates that the following text should be treated as being wrapped in an implicit extern "C" block.



回答3:


There are flags (space separated) and the meaning is:

1 - Start of a new file
2 - Returning to previous file
3 - Following text comes from a system header file (#include <> vs #include "")
4 - Following text should be treated as being wrapped in an implicit extern "C" block.


来源:https://stackoverflow.com/questions/15679756/g-e-option-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!