#line 3 ""是什么意思

ringphone 2006-09-19 11:59:29
看Doxygen的源代码的时候发现有几个文件里有这么一句。
在其scanner.cpp里有很多地方有这种语句:
#line 19 "scanner.l"
只是中间的数字不同,感觉象是把一个文件部分包含进来,看了看MSDN的说明,语焉不详,没怎么明白。
这个scanner.l其实也是一个CPP文件,头疼的是调试跟踪进去的时候中断游标是错行的,就是左边的箭头指的代码行并不是当前运行的代码,这就很吃力了。
请教达人这个#line是干什么用的,为什么要这么写,还有就是怎么跟踪,或者怎么才能改成平常我们习惯的代码。
...全文
434 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
真相重于对错 2006-09-21
  • 打赏
  • 举报
回复
#line 使您得以修改编译器的行号以及(可选)错误和警告的文件名输出。

#line [ number ["file_name"] | hidden | default ]
其中:

number
要为源代码文件中后面的行指定的编号。
"file_name"(可选)
希望出现在编译器输出中的文件名。默认情况下,使用源代码文件的实际名称。文件名必须括在双引号 ("") 中。
hidden
从调试器中隐藏连续的几行,直到遇到另一个 #line 指令为止。
default
重置文件中的行编号。
备注
#line 指令可能由生成过程中的自动中间步骤使用。例如,如果行从原始的源代码文件中移除,但是您仍希望编译器基于文件中的原始行号生成输出,则可以移除行,然后用 #line 模拟原始行号。

#line hidden 指令将从调试器中隐藏连续的几行,这样当开发人员在逐句通过代码时,将会跳过 #line hidden 和下一个 #line 指令(假定它不是另一个 #line hidden 指令)之间的任何行。此选项也可用来使 ASP.NET 能够区分用户定义的代码和计算机生成的代码。尽管 ASP.NET 是此功能的主要使用者,但很可能将有更多的源生成器使用它。

#line hidden 指令不会影响错误报告中的文件名或行号。即,如果在隐藏块中遇到错误,编译器将报告当前文件名和错误的行号。

源代码文件可以具有 #line 指令的任何编号。

jazy 2006-09-21
  • 打赏
  • 举报
回复
不会,就是全局变量“当前文件”“当前行”的值不同而已。
ringphone 2006-09-21
  • 打赏
  • 举报
回复
那就是把说这东西注释掉也不影响编译和调试?
yiwimi 2006-09-20
  • 打赏
  • 举报
回复
帮顶
jazy 2006-09-20
  • 打赏
  • 举报
回复
就是说把__FILE__和__LINE__换成自定义的值,在出错的地方这样做,打印出错信息就可以打出真正引起错误的代码行,而不是出错那行了。
ringphone 2006-09-20
  • 打赏
  • 举报
回复
楼上你贴的就是MSDN里面的,我要明白就不会来问了。你理解这段话吗?给我讲讲,这样写是要达到什么目的,什么情况下会用到?
helldream2002 2006-09-20
  • 打赏
  • 举报
回复
The #line directive tells the preprocessor to change the compiler’s internally stored line number and filename to a given line number and filename. The compiler uses the line number and filename to refer to errors that it finds during compilation. The line number usually refers to the current input line, and the filename refers to the current input file. The line number is incremented after each line is processed.
java反编译工具jad 1.5.8g支持 jdk1.5,jdk1.6。说明很多记住一个万能的命令基本就够用了。jad -sjava -r -8 -o **\*.class ---------------This is README file for Jad - the fast Java Decompiler.Jad home page: http://www.kpdus.com/jad.htmlCopyright 2001 Pavel Kouznetsov (jad@kpdus.com).0. Please read the disclaimer on the Jad home page.1. Installation.Unzip jad.zip file into any appropriate directory on your hard drive.This will create two files: - an executable file named 'jad.exe' (Windows *) or 'jad' (*n*x) - this README fileNo other setup is required.2. How to use JadTo decompile a single JAVA class file 'example1.class' type the following: jad example1.classThis command creates file 'example1.jad' in the current directory.If such file already exists Jad asks whether you want to overwrite it or not.Option -o permits overwriting without a confirmation.You can omit .class extension and/or use wildcards in the names ofinput files.Option -s allows to change output file extension: jad -sjava example1.classThis command creates file 'example1.java'. Be careful when usingoptions -o and -sjava together, because Jad can accidentally overwriteyour own source files.Jad uses JAVA class name as an output file name. For example, if classfile 'example1.class' contains JAVA class 'test1' then Jad will createfile 'test1.jad' rather than 'example1.jad'. If you want to specifyyour own output file name use the output redirection: jad -p example1.class > myexm1.javaOption -d allows you to specify another directory for output files,which are created, by default, in the current directory. For example: jad -o -dtest -sjava *.class (or jad -o -d test -s java *.class, which has the same effect)This command decompiles all .class files in the current directory <

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧