473,804 Members | 2,131 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting all functions from C++ source code

I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.

Thanks in advance!

- Eliss
Jun 27 '08 #1
3 2256
eliss wrote:
I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.
You might want to look into documentation-producing tools, they
usually have pretty decent parsers. See Doxygen or some such.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
On May 9, 5:30*pm, eliss <eliss.carm...@ gmail.comwrote:
I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
* * return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.

Thanks in advance!

- Eliss
It isn't just the grammar that's the problem unless
you're OK with sloppy answers. And if you want to do
this reasonably across thousands of files, I can't
imagine that sloppy answers would be helpful.
You also need to handle the preprocessor, command line switches,
include files, include paths the name resolution problem, too.
In short, you need a full parser for your particular
dialect.

Our DMS Software Reengineering Toolkit has a full C++ parser
for a variety of C++ dialects.
It handles all the above issues,
and collects all this name and type information. What you
want could be pretty easily extracted.

See http://www.semanticdesigns.com/Produ...pFrontEnd.html

Ira Baxter, CTO
Semantic Designs
Jun 27 '08 #3
On May 9, 6:30*pm, eliss <eliss.carm...@ gmail.comwrote:
I'm trying to find a way to extract all the function definitions AND
function uses from thousands of C++ files. For example, if foo.cpp
contains:

int func(char b)
{
* * return 0;

}

func('d'); func('e');
print("bar");

Then I want to get something that tells me "int func(char b) is on
line 1, pos 0 ; func(char) is on line 5, pos 0 ; func(char) is on
line
5, pos 11 ; print(char*) is on line 6, pos 0"

Is there any tool that can do this? I've looked into ctags, but it can
only get the function definitions. I've also tried g++ to see if there
are command line options for this but it doesn't look like it. I've
also tried rolling me own but the amount of grammar that can be used
overwhelmed me.

Thanks in advance!

- Eliss
doxygen can give you all functions. And I'm pretty sure it can give
you call graphs, but I don't think it can give you line and column
numbers. It's worth checking out.

HTH
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3680
by: Calvin FONG | last post by:
Dear all, Are there any utility that can be call by python to create self extracting zip file. I'm now using the powerarchiever. But the command line options aren't flexible enough. Basically, I would like to create a self extracting zip with default file path extraction and force over-write. The powerArchiever just don't let me call it unless I'm using the GUI. Any idea, experience and suggestion are welcome. Thank you. -Calvin
1
1556
by: Philippe C. Martin | last post by:
Hi, How would one go about extracting the pickle module from Python (ex: to make a .a or a .dll) ? Thanks Philippe
0
2948
by: Gnaneshwar Babu | last post by:
Hi I am facing a problem with extracting event logs of win32 to a file. Am using the following code to extract eventlogs to file use Win32::EventLog; $handle=Win32::EventLog->new("System", $ENV{ComputerName}) or die "Can't open Application EventLog\n"; $handle->GetNumber($recs) or die "Can't get number of EventLog records\n";
1
2807
by: Cognizance | last post by:
Hi gang, I'm an ASP developer by trade, but I've had to create client side scripts with JavaScript many times in the past. Simple things, like validating form elements and such. Now I've been assigned the task of extracting content from a given HTML page. If anyone's familiar with the Yahoo! Store order confirmation screen, I need to be able to grab the total amount from the table to the right-hand side. (Sample File:
2
2640
by: Chris Belcher | last post by:
First some background... The database tracks Action Items assigned to a group of 20 or so managers. Once the assignment is created it is then emailed to each of the managers that are included in the scope of the assignment. Among the functions that it provides is the ability to embed the source documents in the database using OLE. The user has requested the ability to forward the source document with the email. The embedded documents...
4
3996
by: Tony Clarke | last post by:
Hi All, I have been trying to extract data from a text file using the fscanf() functions and sscanf() functions. The file is of various characters and integers separated by semicolons, the problem I'm having is that each line is of varying length and the fields separated by semicolons are of varying length also. Is there a way that I could check the first field and depending on this extract data from certain fields contained in this...
2
2820
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to C#. The only significant problem that I have encountered in the conversion is this one - extracting an icon from the 'KTEntryPoint' program into the software suite and placing that icon on the PC Desktop.
0
1485
by: sgsiaokia | last post by:
I need help in extracting data from another source file using VBA. I have problems copying the extracted data and format into the required data format. And also, how do i delete the row that is not required in the output file, in the below example: The row, D0, is not needed. An Example Data Format From the SOURCE file: W1 W2 W3 W4 Oct05 AverageYield 95% 96% 92% 91% 94% D0 0.1 ...
2
4163
by: VictorTan | last post by:
Hello. I'm new to this forum. Hope that I don't make mistakes in here but if I do, please correct me if there is. Thanks. I also wanted to ask you guys regarding about the following following source codes I'm going to post it here as I did a search here and did not find any question related to mine. I'm doing an automatic inventory control system using RFID project and I'm instructed to extract the RFID transponder's ID and CRC and display...
0
9716
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10354
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10101
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9177
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4314
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 we have to send another system
3
3005
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.