How to Identify functions in a .C File??

P

Pardha

can any one help me out in writing a c code for identifying all the
functions present and the number of arguments taken by each function in
a given .C file????

Regards,
Pardha
 
I

Ian Collins

Pardha said:
can any one help me out in writing a c code for identifying all the
functions present and the number of arguments taken by each function in
a given .C file????
Have a look at the gcc source.
 
W

Walter Roberson

can any one help me out in writing a c code for identifying all the
functions present and the number of arguments taken by each function in
a given .C file????

You (or something acting on your behalf) need to parse all the
include files and need to parse the C code in order to determine
such things. Macros and comments and conditional compilation
and quoted strings can all consume apparent declarations,
and macros be used to create code that does not look like declarations
but is.

In short: unless you are forced to write this yourself, use someone else's
pre-written tool for it.

And watch out that the tool matches the compiler version you are using,
as there are compiler extensions in common compilers that result in
declarations being understood where the C language standards would say
the code was invalid.
 
K

Kevin Handy

Do you also need the functions defined in the include files?
The standard include files can define a large number of such
functions that are never used in a specific program.
You (or something acting on your behalf) need to parse all the
include files and need to parse the C code in order to determine
such things. Macros and comments and conditional compilation
and quoted strings can all consume apparent declarations,
and macros be used to create code that does not look like declarations
but is.

To parse the include files, you could use one of the
pre-processors (like the one that comes with gcc), just
make sure that all the defines set up automatically
by the compiler match those used in the pre-processor.
 
B

Barry Schwarz

Do you also need the functions defined in the include files?
The standard include files can define a large number of such
functions that are never used in a specific program.

Most header files do not define functions. They declare them.



Remove del for email
 
P

Pardha

hi,

i need only those functions that are defined in the source file.
i dnt need those functions that that are declared in the header
files...

regards,
Pardha
 
C

CBFalconer

Pardha said:
i need only those functions that are defined in the source file.
i dnt need those functions that that are declared in the header
files...

What, if anything, is this about? Lacking context, it is totally
meaningless. Google is not usenet, it is only a foully
misorganized interface to usenet. There is no reason to assume any
reader has ever, or ever will, receive any particular message.
Thus your articles have to stand by themselves. For means to do
this even via Google, see my sig below. Please read the referenced
URLs.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 
P

pete

Pardha said:
can any one help me out in writing a c code for identifying all the
functions present and the number
of arguments taken by each function in
a given .C file????

That might be tough.
I wrote this code for David Moews Bignum contest a long time ago.
I think there are 66 different functions defined here.

/* pete-4.c */

#define F(Q,R,P) Q(int x){int i=x;while(i--)x=R(x,x);return x;}\
P(int L,int x){int i=x;if(L--)while(i--)x=P(L,x);return Q(x);}

#define Y(A,z,B,C,D,E,G,H,I,J,K,M,N,O,S,T,U,V,W)\
F(A,z,B)F(C,B,D)F(E,D,G)F(H,G,I)F(J,I,K)F(M,K,N)F(O,N,S)F(T,S,U)F(V,U,W)

Z(int L,int x)
{
int i = x;

if(L--)
while(i--)
x = Z(L,x);
return x << x;
}

Y(a,Z,b,c,d,e,g,h,X,j,k,m,n,o,s,t,u,v,w)
Y(Aa,w,Ba,Ca,Da,Ea,Ga,Ha,Ia,Ja,Ka,Ma,Na,Oa,Sa,Ta,Ua,Va,Wa)
Y(Ab,Wa,Bb,Cb,Db,Eb,Gb,Hb,Ib,Jb,Kb,V,U,W,T,S,O,N,M)
F(A,M,B)
F(C,B,D)
F(E,D,G)
F(H,G,I)
F(J,I,K)

int main()
{
return K(99999,9);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top