Re: typical practise for #include's
- From: rziak <news@xxxxxxxx>
- Date: Sat, 26 Nov 2005 11:08:04 -0500
Roman Mashak wrote:
> Hello, All!
>
> I wonder are there any typical, common used practises to organize all
> #include's in the large/medium size project. Try to explain what I mean:
> suppose I have three tranlsation units in project and correspondent header's
> with functions declarations, typedefs and etc.:
>
> unit1.c, unit1.h
> unit2.c, unit2.h
> unit3.c, unit3.h
>
> In my opinion it would be very simple to make ONE big header, call it
> defs.h, which include in every unit's header file. That defs.h would include
> all important headers (suppose stdio.h, stdlib.h, string.h, errno.h so on)
> and also some macros, variables, types. It seems fine, except the issue that
> some of these headers might be useless in other translation units, though
> preprocessor will process it.
>
> Hopefully my explanation is comprehensible :)
>
> With best regards, Roman Mashak. E-mail: mrv@xxxxxxxx
>
>
This seems like scheme Microsoft is using by default in their compilers.
Only they call your "defs.h" as "stdafx.h".
This technique is very effective for generating precompiled headers,
because compiler parses all those headers only once for entire project.
Depends if your compiler supports this method or not. But generally do
not be too concerned with including few thousand lines <stdio.h>
somewhere where it is not needed because time for compilation of file
that small is negligent (few milliseconds on modern machines).
The problem I would like to point out for you is that you get your
global namespace and macro namespace polluted much more this way. Think
how many C programmers use common word macros in place of constants and
inline functions. Or all those IN and OUT macros, Abort or GetTime function.
.
- References:
- typical practise for #include's
- From: Roman Mashak
- typical practise for #include's
- Prev by Date: Re: simple question regarding fact function
- Next by Date: Re: simple question regarding fact function
- Previous by thread: Re: typical practise for #include's
- Next by thread: Little question about what C can do (First steps learner)
- Index(es):
Relevant Pages
|