Hi,
I am wondering if anyone has some insight into a way to get the names of
the functions that are defined in a C header file.
What I am trying to do is develop tests for a large amount of C files.
i have written a Perl script to traverse the directory tree looking for
..h files. i find them and then comes the hard part.
I have found that searching for ";" and then going backwards looking for
close and then open parens gets me to the name, then backing over
whitespace until I find text then getting to the beginning of the text
can give me the name (does this sound like it might net me most of the
functions names ?).
but it can get hairy, since the signatures might not be all on the
same line. I am a newbie to Perl, so that is also a hinderance.
this is what I am trying to accomplish:
I want to open those .h, find the names of the functions, and write a
new .c file that contains test routines for the functions.
For example, if a header file unita.h has 3 functions A, B, C I want to
generate a file called test_unita.c that contains 3 functions,
test_a, test_b, test_c, and a main that calls the 3 functions.
The function bodies for test_a, test_b, test_c will be filled in by
hand, so all I need is the names of the functions.
thanks for reading !
Joe Simon
Newark Valley, NY 4 5234
none <""root\"@(none)"writes:
I am wondering if anyone has some insight into a way to get the names
of the functions that are defined in a C header file.
I'd use an existing program that can already do that, such as
ctags or cscope.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
>I am wondering if anyone has some insight into a way to get the names of
>the functions that are defined in a C header file.
Header files rarely *define* functions; they often declare them, though.
>What I am trying to do is develop tests for a large amount of C files.
i have written a Perl script to traverse the directory tree looking for .h files. i find them and then comes the hard part.
Look at the program "cproto", which generates declarations
for functions in C programs, and obviously knows how to parse
C files.
>I have found that searching for ";" and then going backwards looking for
close and then open parens gets me to the name, then backing over whitespace until I find text then getting to the beginning of the text can give me the name (does this sound like it might net me most of the functions names ?).
but it can get hairy, since the signatures might not be all on the same line. I am a newbie to Perl, so that is also a hinderance.
this is what I am trying to accomplish: I want to open those .h, find the names of the functions, and write a new .c file that contains test routines for the functions. For example, if a header file unita.h has 3 functions A, B, C I want to generate a file called test_unita.c that contains 3 functions, test_a, test_b, test_c, and a main that calls the 3 functions. The function bodies for test_a, test_b, test_c will be filled in by hand, so all I need is the names of the functions.
none wrote:
Hi,
I am wondering if anyone has some insight into a way to get the names of
the functions that are defined in a C header file.
I've used the ctags utility for this purpose before.
santosh wrote:
none wrote:
>Hi, I am wondering if anyone has some insight into a way to get the names of the functions that are defined in a C header file.
I've used the ctags utility for this purpose before.
OK thanks for all the replies, everyone... I'll give check these out !
Joe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Fabio |
last post by:
Hi everyone,
Is there anybody who can suggest me a link where I can find information
about 'Persistent linked list' ?
I need to implement a linked list where every node is a structure like the...
|
by: Srini |
last post by:
Hello,
Rules for inline functions say that they have to be defined in the same
compilation unit as their declarations. For class member functions this
means that the inline member functions must...
|
by: Ross A. Finlayson |
last post by:
Hi,
I hope you can help me understand the varargs facility.
Say I am programming in ISO C including stdarg.h and I declare a
function as so:
void log_printf(const char* logfilename, const...
|
by: Little |
last post by:
Could someone help me get started on this program or where to look to
get information, I am not sure how to put things together.
1. Create 4 double linked lists as follows:
(a) A double linked...
|
by: Little |
last post by:
Could someone help me figure out how to put my project together. I
can't get my mind wrapped around the creation of the 4 double Linked
Lists. Thank your for your insight.
1. Create 4 double...
| |
by: Susan.Adkins |
last post by:
Alright, I must say that the problem my teacher has given us to do has
royally annoyed me.
We are to take a letter *txt file* and then read in the words.
Make 2 seperate lists *even and odd* for...
|
by: citlaly |
last post by:
Hi!!
I'm a beginner in python and I'm trying to use the files from a
"folder" as a list. What I want to do is read each one as a list, but
just the name of the file, the data inside doesn't...
|
by: Kristan |
last post by:
Hi there, quick question, how would I retrieve a list of files in ANSI C in
a purely platform independent way?
Any pointers would be great!
thanks
Kristan
|
by: keclipse2525 |
last post by:
I have a program that is set up like a bank database and I need to use linked list to write all the transactions into a file. Where would you implement the code to write the transactions to a file?...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |