473,657 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code Cleanup Tool

Hi
sorry - I guess this is slightly OT but still ;)

Iam looking for some tool (win32 please) that can find unused member
functions / member variables in my project. Does anyone have any suggestions
there? Google didnt help me much :/

Thanks in advance
Aug 1 '06 #1
6 4154

"Frank Neuhaus" <fn******@uni-koblenz.deschri eb im Newsbeitrag
news:ea******** **@cache.uni-koblenz.de...
Hi
sorry - I guess this is slightly OT but still ;)

Iam looking for some tool (win32 please) that can find unused member
functions / member variables in my project. Does anyone have any
suggestions there? Google didnt help me much :/
Visual Studio >=7.0 with warning level set to "scream-at-me(tm)(c)(R)"
Aug 1 '06 #2
Visual Studio >=7.0 with warning level set to "scream-at-me(tm)(c)(R)"

Thanks for your reply. I just tried that. It already helped a bit - it
reports unreachable code inside functions, unused parameters and unused
global functions. But unfortunately it doesnt report unused member
functions/variables :(
Aug 1 '06 #3
>Visual Studio >=7.0 with warning level set to
"scream-at-me(tm)(c)(R)"

Thanks for your reply. I just tried that. It already helped a bit -
it reports unreachable code inside functions, unused parameters and
unused global functions. But unfortunately it doesnt report unused
member functions/variables :(
unused variables should be listed:

void foo()
{
int a;
int b=0;
}

warning C4101: 'a' : unreferenced local variable
warning C4189: 'b' : local variable is initialized but not referenced

for unused functions - the linker will usually get rid of them. No, I
don't know any tool that can list this for you, because only the
linker knows what functions are used.
Aug 1 '06 #4
Hello Frank,

On Tue, 1 Aug 2006 09:30:08 UTC, "Frank Neuhaus" <fn******@uni-koblenz.dewrote :
Visual Studio >=7.0 with warning level set to "scream-at-me(tm)(c)(R)"

Thanks for your reply. I just tried that. It already helped a bit - it
reports unreachable code inside functions, unused parameters and unused
global functions. But unfortunately it doesnt report unused member
functions/variables :(
You might also try one of the "lint for C++" or static analysis tools
(Klockwork 7?). In general, unused variables and methods in classes
would be very hard to suggest that they weren't used. The linker
could perform such a step if there wasn't a chance that the code/vars
wouldn't be found by other means. Classes do much more than just
group together values and functions that may be unused.

Classes are abstractions of objects that your application may use.
The fact that you don't make use of a particular method doesn't
necessarily mean that it should be removed. You might be planning
on using that component later. The class is a building block for
others to build on. Hopefully the abstraction was valid.

Static analysis tools can find such items to remove. These tools
aren't cheap though. I've not read why you want to remove the
unused components from your code.

I generally review my legacy classes as I work with them to
understand if the abstractions are valid. There are times that
they get rewritten. Certainly if you think a method or value
isn't used -- comment it out, compile, link, and look for the
errors. With less common value/method names you might be able
to get away with a search on the source code.

David
Aug 1 '06 #5
unused variables should be listed:
>
void foo()
{
int a;
int b=0;
}

warning C4101: 'a' : unreferenced local variable
warning C4189: 'b' : local variable is initialized but not referenced

for unused functions - the linker will usually get rid of them. No, I
don't know any tool that can list this for you, because only the linker
knows what functions are used.
I meant member variables - anyway... I know its not relevant for the actual
compiler, but Id like to clean up my code and its kinda hard to do it
manually as the code is too big to instantly know which function is used,
which one is deprecated etc...

So if anyone else has suggestions -...
Aug 1 '06 #6
Frank Neuhaus wrote:
Iam looking for some tool (win32 please) that can find unused member
functions / member variables in my project. Does anyone have any suggestions
there? Google didnt help me much :/
You could try running doxygen over the whole project. If you enable the
"source code browser", it writes a "referenced by..." entry to all
function/member descriptions. You could maybe even tweak it (its
opensource) to output every unreferenced function/member to stderr.

However, beware that virtual member functions are not referenced in this
sense, since this is a static analysis.

Christian
Aug 1 '06 #7

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

Similar topics

6
1467
by: use dmgass at hotmail dot com | last post by:
I'm writing a module and when it is imported by a script I want some code automatically executed when the importing script is finished executing. I'd like it to execute before interactive mode is entered when executing the importing script from the command line. I don't want to have to impose that the importing script must call a function at it's end. Any help is greatly appreciated!!
1
1764
by: djw | last post by:
c.l.p- I am having trouble understanding how one is supposed to correctly utilize try:...except:...finally: in real code. If I have a block of code like: def foo(): try: ... some code that can raise an exception ...
1
1756
by: KevinGPO | last post by:
I got ASP code (VBScript mixed with HTML & Javascript) and am looking for a clean/tidy program to clean up my code. Should I use Dreamweaver cleanup, tool?
1
9739
by: lee_youjin | last post by:
I needed to defect when the user is clicking the IE X button ( top right). so I could execute the cleanup function. I was able to detect it using onbeforeunload event. Now I need to call the function in code behind from onbeforeunload event call. but that is where I have a problem... please refer my code below
1
4567
by: Jason S | last post by:
I haven't used try/catch/finally very much in Javascript. My function (let's call it try_it()) needs to call a function that could throw an exception (let's call it dangerous()) with some setup() beforehand and cleanup() afterwards. What I want to make sure cleanup() is called whether or not dangerous throws an exception, and if it does throw an exception, rethrow the exception to whatever is calling try_it(). In C++ this is much easier...
69
3207
by: MQ | last post by:
Hi all I am just wondering how most people implement cleanup in C functions. In particular, if the function opens a number of resources, these need to be released properly should an error occur at any point in the function (as well as at the end if successful). C++ has exceptions, the only way I can see to do this neatly in C is to use goto statements. Is my method of implementing cleanup good, or are their better ways. Here is an...
3
3617
by: Petr Pavlu | last post by:
Hello, I have two questions how the functions should be written. I read the FAQ but didn't find any answer. If there is any please point me out. I. Cleanup code Consider I have to open file1, then make some malloc and then open file2. What is the best solution how to write the cleanup code? See my pseudo- code ideas.
14
1934
by: Alexander Stoyakin | last post by:
Hello! Please advise on the following issue. I have a function which returns 1 or 0 in multiple branches, and it must perform the same code before each return, like this: int fun() { if (some code) { restore(param1,param2,param3,param4,param5); return 1;
66
3322
by: John | last post by:
Hi What are the advantages actually achieved of managed code? I am not talking of theory but in reality. Thanks Regards
0
8385
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
8303
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
8723
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
7316
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
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
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
2726
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
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
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.