#线 [英] #line

查看:62
本文介绍了#线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白[文件]选项。


如果我写:


#line 100" file" ;


我将文件编号更改为从第100行开始,但是文件是什么。 ?


任何一个例子?


谢谢

Hi, I don''t understand [file] option.

if I write:

#line 100 "file"

I change file numeration to start to line 100 but what "file" ?

any example?

Thanks

推荐答案

6月6日,08:40,xdevel< xdevel1 ... @ gmail.comwrote:
On 6 Jun, 08:40, xdevel <xdevel1...@gmail.comwrote:

我不明白[文件选项。


如果我写:


#line 100" file"


我将文件编号更改为从第100行开始,但是文件是什么。 ?


任何一个例子?
Hi, I don''t understand [file] option.

if I write:

#line 100 "file"

I change file numeration to start to line 100 but what "file" ?

any example?



s 5s with google


" #line linenum filename

linenum与对于第一种形式,并具有相同的效果。

另外,filename是一个字符串常量。以下行和

报告的所有后续行都来自它指定的文件,

,直到其他地方发生变化为止。

它会影响宏__FILE__扩展到的内容。

-

Nick Keighley


恐龙来了又走了,我们Theriodonts仍然是

5s with google

"#line linenum filename
linenum is the same as for the first form, and has the same effect.
In addition, filename is a string constant. The following line and
all subsequent lines are reported to come from the file it specifies,
until something else happens to change that."

it affects what the macro __FILE__ expands to.
--
Nick Keighley

"The Dinosaurs have come and gone, we Theriodonts remain"


在文章< 11 ***************** *****@q69g2000hsb.googlegroups .com> ;,

xdevel< xd ******** @ gmail.comwrote:
In article <11**********************@q69g2000hsb.googlegroups .com>,
xdevel <xd********@gmail.comwrote:

>我不明白[文件]选项。
>Hi, I don''t understand [file] option.


>如果我写:
>if I write:


> #line 100文件
>#line 100 "file"


>我将文件编号更改为从第100行开始,但是文件是什么。 ?
>I change file numeration to start to line 100 but what "file" ?


>任何例子?
>any example?



无论你想要哪个文件;-)

C预处理器通常会放入#line

#include。例如,如果您的源xdev.c有
/ *这是对第1行的评论* /

#include< stdio.h>

/ *这是第3行* /

int foo:


然后预处理器可能将此扩展为

#line 1" xdev.c"


#line 1" stdio.h"


....实际stdio.h内容的行

#line 3" xdev.c"


int foo:

你可能会发生注意到我没有在预处理版本中重现评论

:评论会在预处理阶段转换为空格




#line 1" xdev.c" part表示最初的下一行

来自xdev.c的第1行。之后的空行是什么

最初是xdev.c的第一行,但是因为

这是一个评论而被清空了。之后的行是包含stdio.h的地方,

所以stdio.h的扩展以标记#file 1" stdio.h"

开头说下一行最初来自stdio.h的第1行。

通常stdio.h的第一行是预处理器指令,所以

我显示一个空行,其中预处理器指令得到处理

并转换为空行(以保持行数一致)。

编译器保持相对于最后一行的计数,因此它会知道

表示...实际stdio.h内容的某些行发生了从bdio.h第2行开始的
。最终stdio.h完成并且

发出另一个#line,表示下一个源代码行

最初是xdev.c的第3行。再次,这是一个评论,

被淘汰。从最后一行#line开始再次计算,编译器

知道下一行必须最初来自

xdev.c的第4行。这就是编译器知道的,当它打印出该行的语法错误消息时,它应该抱怨

关于xdev.c的第4行。如果#line不存在,那么在预处理之后

已经扩展了stdio.h以及它所引入的所有内容,编译器

可能会认为它已经在线2500或者其他什么(stdio.h扩展了很多!)

并且用户抱怨

在5号线2503上出错是没有多大意义的行源文件!

-

当时我很年轻,但我也很朦胧。

- Christopher Priest

Whichever file you want ;-)

It is common for C preprocessors to put in #line as they expand each
#include . For example, if your source xdev.c had

/* this is a comment on line 1 */
#include <stdio.h>
/* this is line 3 */
int foo:

then the preprocessor might expand this to
#line 1 "xdev.c"

#line 1 "stdio.h"

.... some lines of actual stdio.h content
#line 3 "xdev.c"

int foo:
You might happen to notice that I didn''t reproduce the comments
in the preprocessed version: comments get converted to spaces
by the preprocessing phases.

The #line 1 "xdev.c" part indicates that the next line originally
came from line 1 of xdev.c . The empty line after that is what
was originally the first line of xdev.c but which got emptied because
it was a comment. The line after that is where stdio.h got included,
so the expansion of stdio.h begins with a marker #file 1 "stdio.h"
saying that the next line originally came from line 1 of stdio.h .
Usually the first line of stdio.h is a preprocessor directive, so
I show an empty line where the preprocessor directive got processed
and converted to an empty line (to keep the line counts consistant).
The compiler keeps count relative to the last #line, so it would know
that the "... some lines of actual stdio.h content" occured
starting at line 2 of stdio.h . Eventually stdio.h finishes and
another #line is emitted to indicate that the next source line
was originally line 3 of xdev.c . Again that was a comment that got
blanked out. Keeping count again from the last #line, the compiler
knows that the next line must have originally been from line 4 of
xdev.c . And that''s how the compiler knows, when it prints out
the syntax error message for that line, that it should be complaining
about line 4 of xdev.c . If #line did not exist, then after preprocessing
had expanded stdio.h and everything that it pulls in, the compiler
might think that it''s on line 2500 or whatever (stdio.h expands a lot!)
and it wouldn''t make much sense to the user to complain about
an error on line 2503 of a 5 line source file!
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest


xdevel写道:
xdevel wrote:

>

我不是了解[file]选项。如果我写:


#line 100" file"


我将文件编号更改为从第100行开始,但是文件是什么? ?


任何一个例子?
>
Hi, I don''t understand [file] option. if I write:

#line 100 "file"

I change file numeration to start to line 100 but what "file" ?

any example?



这与C语言无关,也完全不清楚b $ b。寻找一个处理你的系统的小组,并改善你的问题。


-

< http:/ /www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>

< http://www.securityfocus.com/columnists/423>

< http://www.aaxnet.com/editor/edit043.html>

< http://kadaitcha.cx/vista/dogsbreakfast/index.html>

cbfalconer at maineline dot net


-

通过免费的Usenet帐户发布 http://www.teranews.com

This has nothing to do with the C language, and is also totally
unclear. Look for a group that deals with your system, and improve
your question.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com


这篇关于#线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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