473,394 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Static checker for C++

Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?

Regards,
Chinmoy

Jul 23 '05 #1
9 1498
Chinmoy Mukherjee wrote:
Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?


Welcome to the club!
:-)

Jul 23 '05 #2
Chinmoy Mukherjee wrote:
Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?

Regards,
Chinmoy


From gcc manpage, what about the -Wunsed-macros. Apparently it gives a
warning for each unused macro. Not sure if this works for the inclusion
macros in the header files (#ifndef FILE_H #define FILE_H ... #endif). But
perhaps it will give some hints?

--
Alvin
Jul 23 '05 #3
Alvin wrote:
Chinmoy Mukherjee wrote:
Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?
From gcc manpage, what about the -Wunsed-macros. Apparently it gives

a warning for each unused macro. Not sure if this works for the inclusion macros in the header files (#ifndef FILE_H #define FILE_H ... #endif). But perhaps it will give some hints?


Think about your proposal again ;-)

Jul 23 '05 #4
ab*********@spambob.com wrote:
Alvin wrote:
Chinmoy Mukherjee wrote:
> Hi Friends,
>
> I want to find out whether my C++ code(set of files)
> include some unused header files, do you know of any
> free static checker in linux for the job ?


From gcc manpage, what about the -Wunsed-macros. Apparently it gives

a
warning for each unused macro. Not sure if this works for the

inclusion
macros in the header files (#ifndef FILE_H #define FILE_H ...

#endif). But
perhaps it will give some hints?


Think about your proposal again ;-)


I guess the fact that you have #ifndef FILE_H /uses/ the macro.

--
Alvin
Jul 23 '05 #5
On Fri, 29 Apr 2005 14:41:46 +0530, Chinmoy Mukherjee wrote:
Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?

Regards,
Chinmoy


How about grep?

If the header file isn't being used, then it has not been #include'd
anywhere. Simply search for the name of the header file in your source.
The ones you don't find are not used.

- Jay
Jul 23 '05 #6
Jay Nabonne wrote:
On Fri, 29 Apr 2005 14:41:46 +0530, Chinmoy Mukherjee wrote:

Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?

Regards,
Chinmoy

How about grep?

If the header file isn't being used, then it has not been #include'd
anywhere. Simply search for the name of the header file in your source.
The ones you don't find are not used.


.... or you simply forgot that there is a subdirectory with source files
which actually might use them...

Besides, including a header doesn't necessarily constitute "using". What
if none of the constructs declared/defined in that header are ever used?

V
Jul 23 '05 #7
On Fri, 29 Apr 2005 12:13:17 -0400, Victor Bazarov wrote:
Jay Nabonne wrote:
On Fri, 29 Apr 2005 14:41:46 +0530, Chinmoy Mukherjee wrote:

... or you simply forgot that there is a subdirectory with source files
which actually might use them...


Well, grep -r :)

Besides, including a header doesn't necessarily constitute "using". What
if none of the constructs declared/defined in that header are ever used?


Yep. How the OP meant "using" was a little unclear. Other answers
went in the "nothing in the file is used" direction. I thought I'd throw
that option out, just in case that happened to be what the OP meant.

- Jay
Jul 23 '05 #8
for every cpp file
for every header include
comment out the include
compile the cpp file
if( compile_errors )
un-comment out the header
else
remove header include from cpp

this will work and its not that bad, because you can skip the header you
know are required and consentrate on the others.

I wonder if a compiler plugin could be run overnight to automate this
process, if one could be built
millions of compiling-hours a day could be saved by world-wide developers.
Carl
"Chinmoy Mukherjee" <a1****@motorola.com> wrote in message
news:42**************@motorola.com...
Hi Friends,

I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?

Regards,
Chinmoy

Jul 23 '05 #9
On Fri, 29 Apr 2005 12:34:07 -0400, Carl wrote:
for every cpp file
for every header include
comment out the include
compile the cpp file
if( compile_errors )
un-comment out the header
else
remove header include from cpp


This is how I have had to do it. There is one caveat though: if a header
file contains #defines that control compilation paths, the source file may
compile *error-free* without the header file included, but it may compile
*differently*. So the header file would still be needed to properly
configure the compile.

- Jay

Jul 23 '05 #10

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

Similar topics

467
by: mike420 | last post by:
THE GOOD: 1. pickle 2. simplicity and uniformity 3. big library (bigger would be even better) THE BAD:
49
by: bearophileHUGS | last post by:
Adding Optional Static Typing to Python looks like a quite complex thing, but useful too: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 I have just a couple of notes: Boo...
8
by: spoc | last post by:
I am using VC++6 and Numega bounds checker and have been getting many STATIC MEMORY OVERRUN errors (boundschecker) while trying to track down bugs. An example is below: void func() { static...
3
by: Bas Wassink | last post by:
Hello there, I'm having trouble understanding a warning produced by 'splint', a code-checker. The warning produced is: keywords.c: (in function keyw_get_string) keywords.c:60:31: Released...
44
by: John A. Bailo | last post by:
Dr. Dobbs has a /glowing/ article on Ruby on Rails this month. What do you guys think? Can it replace .net, php and java? And be the Open Source OOP web solution that is not bound to Sun or...
6
by: laikon | last post by:
Hi, everyone, below is my program to test static pointer data member; class A { private: static A* p; protected: A() {} public: static A* init()
13
by: kolmogolov | last post by:
/* Hi, I have removed things irrelevant to reproducing the problem. What's wrong with my code? Thanks in advance for any hint! 1166425362 */ #include <stdio.h> #include <stdlib.h> #include...
6
by: Neil | last post by:
Is there way to have control over the MS-Access spell checking (besides just launching it)? We want to tell it to check all records, but skip certain fields (or, alternatively, ONLY check certain...
0
by: Gert Kok | last post by:
I'd like to use 3 types of objects, which have a kind of availability-check as a static object in their parent class. After page reload the initialised member is NULL Is this a PHP 5.2.5...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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...

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.