473,397 Members | 1,985 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,397 software developers and data experts.

best way to manage the headers..

In my project it is getting really messy to take care of all the
headers..for eg. right now I have following modules in my project -

vector.c
vector.h
test.c
reader.h
reader.c

vector.h

#ifndef VECTOR_H
#define VECTOR_H

#include <math.h>
.....
......

vector.c

#include "vector.h"
........................

reader.h

#ifndef READER_H
#define READER_H

#include <stdio.h>
#include <stdlib.h>
..........................
...........................

And then, I have test.c which needs reader.h, vector.h. But there can
be instances where I may need to include stdio.h and stdlib.h but not
other contents of reader.h. also, it is getting extremely confusing
to manage all the files. So is it a good idea to have a single all.h
file ? My code must be around 7000 lines.
Mar 28 '08 #1
14 1833
On Mar 28, 9:23*am, broli <Brol...@gmail.comwrote:
So is it a good idea to have a single all.h file ?
No, because by multiplexing through a single header, you fold together
the dependency graph, so that then every .c file depends on every .h
file.

Now any time you touch any header, you have to recompile the entire
program.

If you have an "all.h" header, you might as well do away with a
dependency based build system and (for example on Unix) build your
program like this, every time something changes:

cc -o program *.c

Another issue is that recompiling each of the .c files is a bit slower
now because they are including a lot more extraneous material by way
of this all.h.

If every .c file includes every header, than the compilation time for
the program grows quadratically with its size! The more headers there
are, the more material is included into each .c file.

A third issue is that if you ever want to rip code out of this
program, you run into the problem that the code simply includes
"all.h". But you don't want to drag "all.h" along with that small
piece of code. So you have to figure out exactly what it depends on
through "all.h", and take only those headers, and of course edit the
code to include just those headers.

So in other words, this boneheaded practice interferes with some forms
of code reuse.
My code must be around 7000 lines.
That's nothing. For such a small program, it doesn't matter how it's
managed. However, if it ever grows into a alrger program, or you want
to take pieces out of it and use it elsewhere,

There are programs in which just one source file is 7000 lines long.
Mar 28 '08 #2
well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.
which is why i was considering the all.h approach. My project is based
on ray tracing. You have module like -

1. Ray ( Basic Data structure , initialization of rays, creation of
reflected rays, shadow rays etc)

2. Geometry File Reader ( Reads the geometry into my data structures)

3. Octree ( For spatial subdivision of the 3D object)

4. Vector module ( Vector data structure, basic vector functions.)

5. Ray Tracing Module (To keep track of rays)

6. Ray - Triangle Intersection Module
As you can see they are all more or less dependent on each other. One
approach that I saw soemwhere was to define a main.h file.

There were many files in the project -

a.h
a.c

b.h
b.c

c.h
c.c

d.h
d.c

application.h

main.c
main.h

In this, application.h was containing some common #defines, prototypes
of functions in main.c and it included standard headers like stdio,
math, string etc.

main.h was like this -

#ifndef a_h
#include "a.h"
#endif

#ifndef b_h
#include "b.h"
#endif
#ifndef c_h
#include "c.h"
#endif
#ifndef d_h
#include "d.h"
#endif

#ifndef application_h
#include "application.h"
#endif

Then this main.h was included in every .c and .h file...
I thought this was also a neat approach

What do you think ?
Apr 2 '08 #3
broli said:
well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.
You should have thought of that before trolling the group. You'll be in
quite a few killfiles by now.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Apr 2 '08 #4
Richard Heathfield wrote:
broli said:
>well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll be
in quite a few killfiles by now.
indeed...
Apr 2 '08 #5
On Apr 2, 7:40 pm, Richard Heathfield <r...@see.sig.invalidwrote:
broli said:
well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll be in
quite a few killfiles by now.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

thats great!
Apr 2 '08 #6
Richard Heathfield wrote:
broli said:
>well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll be in
quite a few killfiles by now.
He entered mine this morning, so I won't be able to
offer him any help until at least May 1. (First offenders
get a one-month sentence; repeat offenders go into the
Forever File.)

--
Er*********@sun.com
Apr 2 '08 #7
Eric Sosman <Er*********@sun.comwrites:
Richard Heathfield wrote:
>broli said:
>>well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll be
in quite a few killfiles by now.

He entered mine this morning, so I won't be able to
offer him any help until at least May 1. (First offenders
get a one-month sentence; repeat offenders go into the
Forever File.)
That's very interesting Eric. I'm sure we're all very impressed to hear
how you punish perceived offenders.
Apr 2 '08 #8
In article <ft**********@registered.motzarella.org>,
Richard <de***@gmail.comwrote:
>Eric Sosman <Er*********@sun.comwrites:
>Richard Heathfield wrote:
>>broli said:

well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll be
in quite a few killfiles by now.

He entered mine this morning, so I won't be able to
offer him any help until at least May 1. (First offenders
get a one-month sentence; repeat offenders go into the
Forever File.)

That's very interesting Eric. I'm sure we're all very impressed to hear
how you punish perceived offenders.
I'm certainly hanging on every word. Tune in next time for another
episode of... Eric's Killfile!

Apr 2 '08 #9
Eric Sosman wrote:
Richard Heathfield wrote:
broli said:
well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.
You should have thought of that before trolling the group. You'll
be in quite a few killfiles by now.

He entered mine this morning, so I won't be able to
offer him any help until at least May 1. (First offenders
get a one-month sentence; repeat offenders go into the
Forever File.)
Ah. All my plonks are permanent. The idjit made mine as well.


Brian
Apr 2 '08 #10
In article <65*************@mid.individual.net>,
Default User <de***********@yahoo.comwrote:
>Eric Sosman wrote:
>Richard Heathfield wrote:
broli said:

well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll
be in quite a few killfiles by now.

He entered mine this morning, so I won't be able to
offer him any help until at least May 1. (First offenders
get a one-month sentence; repeat offenders go into the
Forever File.)

Ah. All my plonks are permanent. The idjit made mine as well.
Be still, my heart!
>Bwian

Apr 2 '08 #11
broli wrote:
well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.
Terrific. Unfortunately due to your earlier trolling, you will find most
of the /real/ experts have killfiled you. I myself have just done so too.
Apr 3 '08 #12
In article <Lw******************@en-nntp-09.am2.easynews.com>,
Mark McIntyre <ma**********@spamcop.netwrote:
>broli wrote:
>well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

Terrific. Unfortunately due to your earlier trolling, you will find most
of the /real/ experts have killfiled you. I myself have just done so too.
At last. Now, I can sleep at night.

Apr 3 '08 #13
Mark McIntyre wrote:
broli wrote:
>well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

Terrific. Unfortunately due to your earlier trolling, you will
find most of the /real/ experts have killfiled you. I myself
have just done so too.
Well, obviously you still saw him. I didn't.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com

Apr 3 '08 #14
"Default User" <de***********@yahoo.comwrites:
Eric Sosman wrote:
>Richard Heathfield wrote:
broli said:

well in my program, i do have a situation where i need to make
everything(almost) visible to everyone.

You should have thought of that before trolling the group. You'll
be in quite a few killfiles by now.

He entered mine this morning, so I won't be able to
offer him any help until at least May 1. (First offenders
get a one-month sentence; repeat offenders go into the
Forever File.)

Ah. All my plonks are permanent. The idjit made mine as well.


Brian
Really? Very interesting Brian. And this is topical to c.l.c how
exactly? if you were not you I'm sure you would be telling yourself off
now for posting "OT".
Apr 3 '08 #15

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

Similar topics

3
by: Chris Transcend | last post by:
Hi all, I'm writing my first .NET website and am wondering what the best method for including headers and footers is. I was thinking either a user or server control but am not sure which would...
14
by: Howard | last post by:
Hi, I recently had a problem where I decided to store objects in a vector. (Previously, I had always stored pointers in vectors). Well, naturally, when storing an object in a vector, using...
18
by: Carramba | last post by:
Hi! I am wondering what is the best way to control that compiler manage variable names longer then 8 signs. Does it enought to set 2 variables with the same name and difference after 8 sign and...
7
by: Jason | last post by:
We have a developer who claims the Visual Studio designer is not sophisticated enough to build enterprise grade web pages and thus hand codes all of his HTML in such a way as to make the designer...
1
by: JohnH. | last post by:
Hi, Is there a better (best practice) way to do this? I have developed a large set of ASP.NET applications in C#. Like most applications I have a set of utility pages that can be called by...
5
by: l.woods | last post by:
I want your recommendation on which ASP.NET Shopping Cart software I should buy? Best code Best documentation Best support (if needed. I will buying source code, if possible) TIA, Larry...
4
by: DeepDiver | last post by:
I am developing an inventory database in SQL Server. I realize there are many commercial (as well as some non-commercial) inventory offerings, but my client has specific requirements that would...
14
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping"...
4
by: chris | last post by:
I need to maintain a list of subscribers to an email list for a "newsletter" that will be sent via a web form probably once a month. I anticipate low numbers--tens to maybe one hundred subscribers...
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
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,...
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...
0
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,...
0
isladogs
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...

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.