Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Compilation model |
| Date | 2016-11-11 11:55 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o04bie$gb4$1@dont-email.me> (permalink) |
| References | <c7dca28a-32cc-49ec-a4c1-bf7dea851cb7@googlegroups.com> |
On 11/11/2016 11:00, Thiago Adams wrote:
>
> I am start to think a compilation model that consider a group of .c files is good, and I want to know what do you think.
> ----------
>
> Global analysis using current unit model.
> I think each compilation unit will generate the AST.
> So if you have 100 files, that means 100 ASTs that need to be checked for the parts in common. Let's say I have and enum E {A, B, C}
>
> Some of the 100 ASTs can have the E enum being the same entity, each A B C has to be identified as being the same thing. Doing this, the global checker can say "hey look, you have created an C enum value but you never use it in your program".
> ---
The last compiler I did (not for C) only compiles whole projects, as
will the next one (**).
That does have a number of advantages such as those you mentioned. (Also
global optimisations or inlining if I ever get around to doing that.)
However the language being compiled is more strictly modular than C is.
With C, the enum is not really the same one across all modules; each
module just contains an identical definition. (This applies to all
'passive' entities such as enums, typedefs and macros. Only variables
and functions are really shared.)
The problem with C source files, and include files especially, is that
they contain macros, conditional code and so on that are sensitive to
external factors.
Suppose one of the include files makes use of something like __path__ or
__line__ or __time__. Then that could make the following source code be
compiled a little differently.
Or entire blocks of source could be conditional depending on some set,
or not set, by a compiler option, so that your analyser doesn't see
them. Then it becomes harder to do an unequivocal analysis of the source
as it might depend on environmental factors.
--------------------------
(** Actually you compile only one module, and it will then locate and
compile all dependencies based on the 'import' statements seen. If this
is the main module, it will compile the whole program.)
--
Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Compilation model Thiago Adams <thiago.adams@gmail.com> - 2016-11-11 03:00 -0800
Re: Compilation model BartC <bc@freeuk.com> - 2016-11-11 11:55 +0000
Re: Compilation model Thiago Adams <thiago.adams@gmail.com> - 2016-11-11 04:08 -0800
Re: Compilation model "Pascal J. Bourguignon" <pjb@informatimago.com> - 2016-11-12 12:52 +0100
Re: Compilation model Thiago Adams <thiago.adams@gmail.com> - 2016-11-12 13:47 -0800
Re: Compilation model Thiago Adams <thiago.adams@gmail.com> - 2016-11-12 17:10 -0800
csiph-web