Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

#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

On 6 Jun, 08:40, xdevel <xdevel1@gmail.com> 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?

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"

In article <1181115654.570708.270@q69g2000hsb.googlegroups.com>,

xdevel  <xdevel1@gmail.com> 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?

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

CBFalconer <cbfalco@yahoo.com> 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" ?
> 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.

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

CBFalconer <cbfalco@yahoo.com> writes:
> 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) k@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"

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>

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>

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

CBFalconer <cbfalco@yahoo.com> writes:

[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) k@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"

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc