Marco van de Voort wrote:

> > Do you mean that only one level of dependencies must be checked with
> > "uses", whereas even the indirectly #included files must be checked for
> > changes?
> 
> You always have to do the #include. Always. Pre-compiled headers are
> possible, not trivial, since it requires a comparison of the entire
> preprocessor state to see if a header needs recompilation.

With precompiled headers it's almost like with compiled units: every
compiled file contains a list of dependend files, dates and/or
checksums. If something has changed, the affected unit or module must be
recompiled. If nothing has changed, the preprocessor states can not have
changed as well.

> > > That allows the compiler to auto-find the compilation order..

A compilation order only applies to units. A Pascal compiler or linker
starts with the root unit, and then descends into all used units. C
projects instead consist of a single (flat) list of modules, which can
be compiled in any order.


> > A C project doesn't require any compilation order, every module can be
> > compiled independently from other modules.
> 
> Implementation: yes. Header: no.

Hmm, perhaps we have a different idea of precompiled header files. Let
me explain what BC 3.1 did:

Header files are not precompiled for themselves, one by one, instead
there must exist something like a root module (*.c) which contains a
list of #include's. These included files are precompiled together, in
the given order. 
Multiple modules can share the same precompiled headers only if the
modules #include the same header files in the same sequence.

The precompiled header files, for all modules of a project, reside in
the same precompiled file. This file in fact is a library, containing
distinct sets of precompiled headers, in different extent or order. IOW
modules with exactly the same #include's in sequence share a single
precompiled header module. The file may be organized as a tree of header
modules, with bifurcations when different files are #included after a
preceding identical sequence.

Borland also introduced a #pragma headerstop, that delimits the list of
precompiled header files. All modules with the same #include's before
this pragma can share the same header module, eventually following
#includes are not precompiled. This feature allows to precompile a
reasonable number of header files into one header module. AFAIR it was
easier to #include exactly the same header files in all modules of a
project, regardless of the actual needs of every module. The resulting
precompiled header file, for a Win3.1 project, then could be as small as
20 MB, in contrast to > 80 MB for less, but different, #includes in the
source modules.

Regardless of such optimization, as long as the header files are not
touched themselves, and the #include's in the source modules are
unchanged, a recompilation of the header files is never required.

DoDi


_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to