以#1" a.c"这样的散列符号和数字开始的行的含义是什么在gcc预处理器输出中? [英] What is the meaning of lines starting with a hash sign and number like '# 1 "a.c"' in the gcc preprocessor output?

查看:113
本文介绍了以#1" a.c"这样的散列符号和数字开始的行的含义是什么在gcc预处理器输出中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打印出C预处理器的输出,使用

  gcc -E ac 


  


> #1ac
#1< built-in>
#1< command-line>
#1ac
#1c:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ /../../include/stdio.h1 3
#19c:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ /../../../../include/stdio.h3
#1c:\\\\\\\\\\\\\\\\\\\\\ lib / gcc / mingw32 / 4.5.0 /../../../../include/_mingw.h1 3
#31c:\\\\\\\\\\\\\\\\\\\\\\\\\\ ./lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h3

#32c:\\mingw\\ \\\\\ ../ lib / gcc / mingw32 / 4.5.0 /../../../../include/__mingw.h3
#20c:\\ \\\\\\\\\\\\\\\\\\/../../../../../../../../../../../../../../../../../../../../../../ lib / gcc / mingw32 / 2/3 / $ / $ / $

我从来没有在C中看到过这种语法。有人可以解释这是干什么吗?

解决方案

这些行提示用于调试(其中代码行后面的代码实际来自这些行)

 #line-numb呃source-file[flags] 

标志的含义(空格分隔):




  • 1 - 新文件开始

  • 2 - 返回到前一个文件
  • 3 - 下面的文本来自系统头文件(#include<> vs #include)

  • 4 - 下面的文本应该被视为包含在隐式的extern C块。


I print out the output of C preprocessor by using

gcc -E a.c

The output contains many lines like

# 1 "a.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "a.c"
# 1 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/stdio.h" 1 3
# 19 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/stdio.h" 3
# 1 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h" 1 3
# 31 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h" 3

# 32 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/_mingw.h" 3
# 20 "c:\\mingw\\bin\\../lib/gcc/mingw32/4.5.0/../../../../include/stdio.h" 2 3

I never seen this kind of syntax in C. Can someone explain what this is doing?

解决方案

These lines are hints for debugging (where the code following the line actually came from)

# line-number "source-file" [flags]

Meaning of flags (space separated):

  • 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.

这篇关于以#1&quot; a.c&quot;这样的散列符号和数字开始的行的含义是什么在gcc预处理器输出中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆