ctags and function prototypes

Tom Mackey tomm at voodoo.voodoo.uucp
Wed Oct 31 06:15:11 AEST 1990


    I'm trying to DoTheRightThing and use full function prototyping
    and have run into a little problem with ctags.  I wonder whether
    there is a problem with the parsing mechanism in ctags, or if I
    am doing the prototypes incorrectly.  Allow me to demonstrate.

    I am writing a declaration for a function which takes a pointer to
    an integer, a pointer to a function which returns void and itself
    takes a pointer to void (generic pointer), and a third parameter
    which is a pointer to void.  Here's the declaration:

void   my_func(int *, void ((*fn)(void *)), void *);

    And here is a definition, body left empty since it is
    immaterial to the discussion at hand:

void my_func(int *flag, void (*sfunc)(void *), void *arg)
{
    /* Do Whatever */
}

    Now, if I run ctags on this, here is what I get:

Script started on Tue Oct 30 10:52:37 1990
tomm logging onto hank:/dev/ttyq7 at 10:52:37 AM on Tue 30_Oct_90
% cat foo.c
void    my_func(int *, void (*fn)(void *), void *);

void my_func(int *flag, void (*sfunc)(void *), void *arg)
{
    /* Do Whatever */
}

% ctags foo.c
Duplicate entry in file foo.c, line 3: my_func
Second entry ignored
% cat tags
my_func foo.c   /^void    my_func(int *, void (*fn)(void *), void *)/
% exit
% 
script done on Tue Oct 30 10:52:56 1990

    OK.  Now I'll reduce the declaration by removing most of that
    function pointer prototype:

Script started on Tue Oct 30 11:08:45 1990
tomm logging onto hank:/dev/ttyq7 at 11:08:45 AM on Tue 30_Oct_90
% cat foo.c
void    my_func(int *, void (*fn), void *);

void my_func(int *flag, void (*sfunc)(void *), void *arg)
{
    /* Do Whatever */
}

% ctags foo.c
% cat tags
my_func foo.c   /^void my_func(int *flag, void (*sfunc)(void *), voi/
% exit
% 
script done on Tue Oct 30 11:09:00 1990

    That worked OK.... tags contains the actual function definition.
    Now I'll add back in the paren-pair for the function pointer:


Script started on Tue Oct 30 11:11:01 1990
tomm logging onto hank:/dev/ttyq7 at 11:11:01 AM on Tue 30_Oct_90
ca% t foo.c
void    my_func(int *, void (*fn)(), void *);

void my_func(int *flag, void (*sfunc)(void *), void *arg)
{
    /* Do Whatever */
}

% ctags foo.c
Duplicate entry in file foo.c, line 3: my_func
Second entry ignored
% cat tags
my_func foo.c   /^void    my_func(int *, void (*fn)(), void *);$/
% exit
% 
script done on Tue Oct 30 11:11:22 1990

    Oops!  Bad news.  The tags file contains the function declaration.
    What gives?  Any ideas?

--
Tom Mackey       (206) 865-6575        tomm at voodoo.boeing.com
Boeing Computer Services         ....uunet!bcstec!voodoo!tomm
M/S 7K-20,     P.O. Box 24346,     Seattle, WA     98124-0346



More information about the Comp.sys.sgi mailing list