


#15 line number of *start* of declaration


function(int x);

&gt; ctags --excmd=number --c++-types=p -f - temp4.h

function temp4.h 2;&quot; p

As you see, ctags is outputting line number 2 instead
of 1. There should definitely be a way to make ctags
output the line of the beginning of the declaration,
especially because when processing ctags output in a
program it's easy to go from the beginning to the end
even without a real parser but going backwards and
finding the start of the declaration is very hard to
implement (especially if you process files 1 line at a
time in an awk script as I'm doing right now).


  • Darren Hiebert
    Darren Hiebert

    Logged In: YES

    Ctags records the line on which a given name is defined, not
    the statement which defines the name. I cannot agree that
    this suggestion is useful in general. In my own use of
    ctags, I want to go to where the name is found.

    Secondly, the ctags &quot;parser&quot; is not a real parser, but a
    crude parser which is very imprecise, partly because of the
    problems caused by macros (which often result in
    syntactically invalid code), which would break a real
    parser. It would be too much work to make ctags work this
    way. Further, if I did, it would never be completely correct
    because of macros.

    It seems too much work for me to engage for limited benefit.
    You are welcome to see what you can do, though, since ctags
    is licensed under GPL.

  • Darren Hiebert
    Darren Hiebert

    • status: open --> closed-rejected