Discussion:
gcc: extract function prototypes
(too old to reply)
rhXX
2007-05-15 15:06:53 UTC
Permalink
hi,

is there any option of gcc in order to extract the function prototypes
of the functions written in a file (.c or .c++) ?

i would appreciate very much any comment or help

tks in advance
W***@gmail.com
2007-05-16 10:18:00 UTC
Permalink
Post by rhXX
hi,
is there any option of gcc in order to extract the function prototypes
of the functions written in a file (.c or .c++) ?
i would appreciate very much any comment or help
tks in advance
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
rhXX
2007-05-17 11:51:07 UTC
Permalink
Post by W***@gmail.com
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
i'm not sure, but many years ago, i remember that there was an option
in the compiler (maybe borland C???) that generate all the prototypes
of the project.

now i wanted to include this option in the makefile and have all
prototypes updated. really it is not a BIG project, only i want to do
it .... im not working with ide enviroment but simple comand line

just yesterday i found in internet cprot (already refered in the next
answer), it worked ok for C

tks a lot!
Thomas Dickey
2007-05-16 10:42:57 UTC
Permalink
Post by rhXX
hi,
is there any option of gcc in order to extract the function prototypes
of the functions written in a file (.c or .c++) ?
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
ftp://invisible-island.net
rhXX
2007-05-17 11:54:04 UTC
Permalink
Post by Thomas Dickey
Post by rhXX
hi,
is there any option of gcc in order to extract the function prototypes
of the functions written in a file (.c or .c++) ?
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. Dickeyhttp://invisible-island.netftp://invisible-island.net
tks a lot! yesterday, before i read ur note, i found internet cproto,
i compiled it and worked fine. anyway i will check ur link also about
protoize.

tks very much!
rhXX
2007-05-18 10:48:38 UTC
Permalink
Post by Thomas Dickey
protoize works for C (except that it changes the parameter types).
cproto also works for C (doesn't change the parameter types).
hi thomas,

i was looking about protoize, but i'm a bit confused:

protoize works in the same .c file, and as u told, it changes the
parameters types, for example a function i wrote as

test() it changes to test(void)

that is ok

it introduces at the begining of .c file, ONLY the prototypes of
functions forward refered, not ALL of the functions defined in the
file, ok????

the huge .X file contains ALL the definition found for that .c file
including ALL the headers found?

cproto, gives me a cute file, only with the functions defined in
the .c file. ok?????

so i can't obtain the similar results of cproto with protoize?????

tks in advance
rhXX
2007-05-18 11:09:14 UTC
Permalink
Post by Thomas Dickey
protoize works for C (except that it changes the parameter types).
so at the end, the useful file, .X, can be obtained directly with the
option -aux-info in gcc??? (very huge file)

in this case any .c or .h file are changed

ok???
tks in advance
Thomas Dickey
2007-05-22 11:54:14 UTC
Permalink
Post by rhXX
Post by Thomas Dickey
protoize works for C (except that it changes the parameter types).
cproto also works for C (doesn't change the parameter types).
hi thomas,
protoize works in the same .c file, and as u told, it changes the
parameters types, for example a function i wrote as
test() it changes to test(void)
that's ok, but not what I meant. Something like

int foo(a) char a; {}

would be handled by protoize as

int foo(char a) {}

which may seem right, except that's not the way K&R code is mapped to ANSI.
The default promotion rule for "char a;" makes it really "int a;":

int foo(int a) {}
--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
Loading...