Re: About different versions of the same header files
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 26 Sep 2007 12:54:05 -0700
CBFalconer <cbfalconer@xxxxxxxxx> writes:
"parag_paul@xxxxxxxxxxx" wrote:
Suppose I have a huge code base, And I have a very common header
file. Now there are mulitple places where this header file is kept.
This header file cannot be factored as it has different function
prototypes in different places. Now can there be a safeguard at
compile time to maintain the #defines in the different headers
files to be same .
ie suppose I add a new type in one of the header files and then
want that compile fails in the other directories which has the
header file with the same name, unless all the #defines are same
in all.
Don't do that. The only purpose of header files is to allow use of
the C file in other compilations, i.e. to specify the interface.
Not all headers are associated with C files; some just have macro
definitions, typedefs, and so forth. <stdint.h> is an example.
You should have only one copy of such a header, and it should not
change (barring early development). If it needs to appear in
multiple locations consider using links, rather than file copies.
(U/Linux).
I don't see why it would *need* to be in multiple locations. It
should be possible to have one copy in one place, and refer to it from
anywhere within the project.
But the OP's problem is that he's dealing with a huge code base that's
*already* a mess; it's a little late for "Don't do that".
If there are chunks of the header that need (for now) to be different,
and other parts that are still consistent, it probably makes sense to
split the header into two parts, one that's identical across all
copies (or, better, stored in only one place), and another that
reflects the current inconsistencies. This will require updating a
lot of '#include' directives, but it should be possible to automate
that. Over time, try to migrate declarations from the multiple
inconsistent headers into the single shared header, updating client
code as needed. This can be done incrementally, and *eventually* you
should be able to get rid of the multiple inconsistent headers.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- References:
- About different versions of the same header files
- From: parag_paul@xxxxxxxxxxx
- Re: About different versions of the same header files
- From: CBFalconer
- About different versions of the same header files
- Prev by Date: Re: removing comment
- Next by Date: Re: switch on strings
- Previous by thread: Re: About different versions of the same header files
- Next by thread: Re: About different versions of the same header files
- Index(es):
Relevant Pages
|
|