[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: line numbers in code



On Fri, 25 May 2001, john gennard wrote:

> I'm having to look for certain lines in code and have been doing so
> by laboriously counting down the program. As many error messages
> make reference to line numbers, I feel sure there must be a simple
> way to locate say 'line 1267' How do people go about this?
>
> Thanks,        John.

The C preprocessor has a __LINE__ directive that is replaced by the line
number.

You can run *any* text through cpp (not just C program sources, I use it
for my Fortran codes:)


$echo '__LINE__' | cpp -P
1

(-P prevents the output of weird stuff for gcc )


HTH,
Romain

--
Qui donne au pauvre prête a Dieu.
Victor Hugo, Les Voix intérieures



Reply to: