473,378 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

#line

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

Jun 6 '07 #1
11 2768
On 6 Jun, 08:40, xdevel <xdevel1...@gmail.comwrote:
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?
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"

Jun 6 '07 #2
In article <11**********************@q69g2000hsb.googlegroups .com>,
xdevel <xd********@gmail.comwrote:
>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?
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
Jun 6 '07 #3
xdevel wrote:
>
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?
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

Jun 6 '07 #4
CBFalconer <cb********@yahoo.comwrote:
xdevel wrote:
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" ?
This has nothing to do with the C language, and is also totally
unclear.
Unclear, perhaps, but it certainly is a C question, and one which
6.10.4 of n869 answers. (Walter also gave a helpful and on-topic
response.)

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Jun 6 '07 #5
Op Wed, 06 Jun 2007 11:16:41 -0400 schreef CBFalconer:
xdevel wrote:
>>
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?

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.
Not quite, I found this in n1124.pdf on page 538
"#line preprocessing directive, 6.10.4"
--
Coos
Jun 6 '07 #6
CBFalconer <cb********@yahoo.comwrites:
xdevel wrote:
>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?

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.
Chuck, you're mistaken. The #line directive (which takes an optional
file name) is standard. See C99 6.10.4p4.

It affects __LINE__ and __FILE__, and it's likely to affect diagnostic
messages.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 6 '07 #7
CBFalconer wrote:
xdevel wrote:
>>
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?

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.
The #line directive has been standard C since C89.

--
Tor <torust [at] online [dot] no>

Jun 6 '07 #8
xdevel wrote:
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?
Not long ago, I posted a lex example here, where I had written something in
a file called "ex_lex.l", which was passed through a tool, which generated
a C source file called "lex.yy.c".

Now, take a look into the C source file that was generated:

$ more lex.yy.c
....

#line 1 "ex_lex.l"
/*
Compile:
flex ex_lex.l
cc lex.yy.c -ll

Run:
../a.out < ex_lex.l
*/
#line 11 "ex_lex.l"
#line 462 "lex.yy.c"
....

From the above, you can see that the tool, which generated the source, made
reference back to the file I had written (ex_lex.l). The line command
affect the values of the __LINE__ and the __FILE__ macros.

The point is, that when you compile a generated source file, you get a
reference back to the original file, which was used as input to the tool
and more meaningful diagnostic messages can result.

--
Tor <torust [at] online [dot] no>

Jun 6 '07 #9
Christopher Benson-Manica wrote:
CBFalconer <cb********@yahoo.comwrote:
>xdevel wrote:
>>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" ?
>This has nothing to do with the C language, and is also totally
unclear.

Unclear, perhaps, but it certainly is a C question, and one which
6.10.4 of n869 answers. (Walter also gave a helpful and on-topic
response.)
Woops, I goofed. Sorry.

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

Jun 7 '07 #10
CBFalconer <cb********@yahoo.comwrites:
[snip]
Woops, I goofed. Sorry.
Let that be an example for everyone. If you make a mistake (and it
*will* happen), admit it and move on.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 7 '07 #11
On Wed, 06 Jun 2007 11:41:30 -0700, Keith Thompson <ks***@mib.org>
wrote:
CBFalconer <cb********@yahoo.comwrites:
<snip about #line 100 "file">
Chuck, you're mistaken. The #line directive (which takes an optional
file name) is standard. See C99 6.10.4p4.

It affects __LINE__ and __FILE__, and it's likely to affect diagnostic
messages.
And also likely to affect <OT non-Standarddebugger information, on
implementations that have a debugger and debugger information and if
any applicable options to control that information are enabled. </>

- formerly david.thompson1 || achar(64) || worldnet.att.net
Jul 1 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Peter A. Schott | last post by:
Per subject - I realize I can copy/paste a line at a time into an interactive session when I'm trying to debug, but was wondering if there is any tool out there that allows me to copy sections of...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
3
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. ...
9
by: Adi | last post by:
Hello eveyone, I wanna ask a very simple question here (as it was quite disturbing me for a long time.) My problem is to read a file line by line. I've tried following implementations but still...
6
by: magix | last post by:
Hi, when I read entries in file i.e text file, how can I determine the first line and the last line ? I know the first line of entry can be filtered using counter, but how about the last line...
6
by: Jacob Rael | last post by:
Hello, I have a simple script to parse a text file (a visual basic program) and convert key parts to tcl. Since I am only working on specific sections and I need it quick, I decided not to...
14
by: WStoreyII | last post by:
the following code is supposed to read a whole line upto a new line char from a file. however it does not work. it is producing weird results. please help. I had error checking in there for...
19
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
This is an example of the data; 2007/07/27 11:00:03 ARES_INDICATION 010.050.016.002 404.2.01 (6511) RX 74 bytes 2007/07/27 11:00:03 65 11 26 02 BC 6C AA 20 76 93 51 53 50 76 13 48...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.