Are there any C tools that can find redundant #includes in a project,
so as to shorten compile time? Of course, eliminating single
#includes by hand and determining if the recompile fails is one
option, though that is an extremely manual and time-intensive
approach. Thanks,
--
Benjamin 15 2774
Benjamin Rutt <br********@blo omington.in.us> wrote in
news:wc******** *****@mu.cis.oh io-state.edu: Are there any C tools that can find redundant #includes in a project, so as to shorten compile time? Of course, eliminating single #includes by hand and determining if the recompile fails is one option, though that is an extremely manual and time-intensive approach. Thanks,
This trick will eliminate including the same file multiple times per
compile:
/* foo.h
*/
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
/* foo.h file contents
*
#endif /* FOO_H_INCLUDED */
--
- Mark ->
--
"Mark A. Odell" <no****@embedde dfw.com> writes: This trick will eliminate including the same file multiple times per compile:
/* foo.h */ #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED
/* foo.h file contents *
#endif /* FOO_H_INCLUDED */
Thanks, I'm sorry, I knew of that trick actually, and I've rarely seen
a header file without it...I guess I misstated my question. I was
actually talking about #includeing files that you don't need at all,
not even once, so my using 'redundant' was incorrect. I should have
asked:
How do you find which header files aren't used at all by a single
compilation unit, and can safely be deleted from a the .c file?
--
Benjamin
Benjamin Rutt wrote: How do you find which header files aren't used at all by a single compilation unit, and can safely be deleted from a the .c file?
I believe this falls under the topic of "lint," such as declaring unused
variables, code blocks that do nothing (ie "if (0 == 1) {[...]}", etc...),
redundant stuff ("a = 1; a = 5"), and all the other junk that accumulates
as projects evolve.
I would use a lint checker for that.
I have used the Gimpel lint checker ( www.gimpel.com) quite successfully,
I'm sure there are others including free ones.
--
gabriel
Mark A. Odell wrote: Benjamin Rutt <br********@blo omington.in.us> wrote in news:wc******** *****@mu.cis.oh io-state.edu:
Are there any C tools that can find redundant #includes in a project, so as to shorten compile time? Of course, eliminating single #includes by hand and determining if the recompile fails is one option, though that is an extremely manual and time-intensive approach. Thanks,
This trick will eliminate including the same file multiple times per compile:
/* foo.h */ #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED
/* foo.h file contents *
#endif /* FOO_H_INCLUDED */
The file opening time may be reduced by using:
#ifndef FOO_H_INCLUDED
#include "foo.h"
#endif
Finding and opening a file is one of the major items
for compilation times. Also, in Mark's version, the
compiler must scan all the code looking for the
#endif, which takes time.
--
Thomas Matthews
C++ newsgroup welcome message: http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq: http://www.raos.demon.uk/acllc-c++/faq.html
Other sites: http://www.josuttis.com -- C++ STL Library book
Thomas Matthews <Th************ *************** *@sbcglobal.net > wrote in
news:tK******** ***********@new ssvr16.news.pro digy.com: This trick will eliminate including the same file multiple times per compile:
/* foo.h */ #ifndef FOO_H_INCLUDED #define FOO_H_INCLUDED
/* foo.h file contents *
#endif /* FOO_H_INCLUDED */
The file opening time may be reduced by using: #ifndef FOO_H_INCLUDED #include "foo.h" #endif
Finding and opening a file is one of the major items for compilation times. Also, in Mark's version, the compiler must scan all the code looking for the #endif, which takes time.
Doesn't this approach become cumbersome and error prone with many source
files and many header files? The standard way I mentioned means that the
user of the header file can blissly include the header file without fear
of multiple definition warnings.
--
- Mark ->
--
Thomas Matthews wrote: The file opening time may be reduced by using:
#ifndef FOO_H_INCLUDED #include "foo.h" #endif
Finding and opening a file is one of the major items for compilation times. Also, in Mark's version, the compiler must scan all the code looking for the #endif, which takes time.
No!
The C preprocessor remembers the names of *idempotent* header files
and will *not* attempt to find, open or read them a second time.
Your suggestion is out-of-date and no longer necessary or useful.
"E. Robert Tisdale" <E.************ **@jpl.nasa.gov > writes: Thomas Matthews wrote:
The file opening time may be reduced by using: #ifndef FOO_H_INCLUDED #include "foo.h" #endif Finding and opening a file is one of the major items for compilation times. Also, in Mark's version, the compiler must scan all the code looking for the #endif, which takes time.
No!
The C preprocessor remembers the names of *idempotent* header files and will *not* attempt to find, open or read them a second time. Your suggestion is out-of-date and no longer necessary or useful.
No, some implementations of the C preprocessor do this. I have no
idea how many, but it's unwise to assume that they all do. (Not that
it matters, since there's no real functional difference.)
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
E. Robert Tisdale wrote: The C preprocessor remembers the names of *idempotent* header files and will *not* attempt to find, open or read them a second time. Your suggestion is out-of-date and no longer necessary or useful.
Cammon, you know better than that! Of course, _some_ implementations might
do this, but then if you want to bring up implementation-specific features,
then I could chime in and say we're all fool for discussing this topic
given that precompiled headers exist.
--
gabriel This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: max(01)* |
last post by:
hi everybody.
suppose that code-1.py imports code-2.py and code-3.py (because it uses
names from both), and that code-2.py imports code-3.py.
if python were c, code-1.c should only *include* code-2.c, because the
latter in turns includes code-3.c.
inclusion of modules in c is a purely preprocessing textual matter
(compilation is deferred to after the fact), i guess, so that such
|
by: Aaron W. West |
last post by:
Timings... sometimes there are almost too many ways to do the same thing.
The only significant findings I see from all the below timings is:
1) Integer math is generally fastest, naturally. Bigint math isn't much
slower, for integers that all fit within an integer.
2) Converting float to varchar is relatively slow, and should be avoided if
possible. Converting from integer to varchar or varchar to int is several
times faster.
|
by: Chris Gordon-Smith |
last post by:
I am currently revisiting the code of a C++ application and restructuring
the code where appropriate to make it consistent with the overall logical
design.
As part of this, I am looking at the way .cpp files #include headers. My
question is this: Is there a standard order in which heders should be
included?
I tend to #include STL headers first, and my own headers later, but I can't
really think of a logical justification for this.
|
by: Mark Dickinson |
last post by:
I have a simple 192-line Python script that begins with the line:
dummy0 = 47
The script runs in less than 2.5 seconds. The variable dummy0 is never
referenced again, directly or indirectly, by the rest of the script.
Here's the surprise: if I remove or comment out this first line, the
script takes more than 15 seconds to run. So it appears that adding a
redundant line produces a spectacular six-fold increase in speed!
|
by: ralphNOSPAM |
last post by:
Is there a PHP script that can find unused variables? I'd like to
'clean up' my scripts.
Thanks...
| |
by: David Muoio |
last post by:
I am trying to validate an XML file against an XSD that is stored in the
assembly as an embedded resource. I can get it to work as long as the XSD
does not include other XSDs. After a fair amount of searching, I have found
3 possible solutions but none have worked for me. They are:
1. Use the Includes property of XmlSchema to add included XSDs, then call
Compile
XmlSchema mainSchema = XmlSchema.Read( stream1, null );
XmlSchema ...
|
by: Jim |
last post by:
Hi:
Do we have some common style for includes when working on a project
with lots of c and h files. Wat I mean is do we have a rule in C when
a file includes several files and those file in turn can call back it.
So do we keep the includes in the source file or in its header file
and just call the header from the c file. Are there any more rules
when we go for includes. Thanx to yu all who bother to share....
su
|
by: smachin1000 |
last post by:
Hi All,
Does anyone know of a tool that can automatically analyze C source to
remove unused #includes?
Thanks,
Sean
|
by: Astley Le Jasper |
last post by:
Sorry for the numpty question ...
How do you find the reference name of an object?
So if i have this
bob = modulename.objectname()
how do i find that the name is 'bob'
|
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,...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |