2007/05/15

extraction of function prototypes from C source file

http://rpmfind.net/linux/RPM/netwinder/netwinder/RPMS/dm/3.1-15/cproto-4.6-2.armv4l.html

Cproto generates function prototypes and variable declarations from
C source code. Cproto can also convert function definitions between the
old style and the ANSI C style. This conversion will overwrite the
original files, however, so be sure to make a backup copy of your original
files in case something goes wrong. Since cproto uses a Yacc generated
parser, it shouldn't be confused by complex function definitions as much
as other prototype generators) because it uses a Yacc generated parser.

Cproto will be useful for C programmers, so install cproto if you are going
to do any C programming.

http://rpmfind.net/linux/rpm2html/search.php?query=cproto

    rpm -Uvh -vv cproto-4.7c-3.src.rpm

    /usr/src/packages/SOURCES % ll
    1219 Sep 9 2004 cproto-4.6-bison.patch
    267 Sep 9 2004 cproto-4.6-varargs.patch
    1762 Sep 9 2004 cproto-4.6.1-patch
    118592 Jun 25 2004 cproto-4_7c.tgz

    gunzip cproto-4_7c.tgz
    tar -xvf cproto-4_7c.tar
    cd cproto-4_7c
    ./configure
    make


Makefile:
    proto:
      cproto $(SRCS) > ./prototypes_aux.h


#===============================
protoize works for C (except that it changes the parameter types).
cproto also works for C (doesn't change the parameter types).

http://invisible-island.net/cproto/

--
Thomas E. Dickey
http://invisible-island.net


#===============================
William.Deans@gmail.com

I am sure there is a better solution than this, but in case no one
steps forward with one:
---------------------

Greetings,

I don't know the answer to your question but I do know that some IDE's
have a tree view which includes functions prototypes. If your job was
on a medium to large scale you could automate the extraction using
that code. Simply modify the IDE such that it logs the function
prototypes as it adds them to the tree view. Unless you run into some
difficulty, I do not see why this logging code should take longer than
a few minutes to add.

Hope this helps,
William

#================================================
http://www.cs.cmu.edu/cgi-bin/info2www?(gcc.info)C%20Dialect%20Options

Options Controlling C Dialect
=============================
`-aux-info FILENAME'
Output to the given filename prototyped declarations for all
functions declared and/or defined in a translation unit, including
those in header files. This option is silently ignored in any
language other than C.

Besides declarations, the file indicates, in comments, the origin
of each declaration (source file and line), whether the
declaration was implicit, prototyped or unprototyped (`I', `N' for
new or `O' for old, respectively, in the first character after the
line number and the colon), and whether it came from a declaration
or a definition (`C' or `F', respectively, in the following
character). In the case of function definitions, a K&R-style list
of arguments followed by their declarations is also provided,
inside comments, after the declaration.


$(CC) -c $(CFLAGS) -aux-info $<.X -o $@ $<

No comments: