Deutsch English Français Italiano |
<vi6sb1$148h7$1@paganini.bofh.team> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!newsfeed.bofh.team!paganini.bofh.team!not-for-mail From: antispam@fricas.org (Waldek Hebisch) Newsgroups: comp.lang.c Subject: Re: question about linker Date: Wed, 27 Nov 2024 10:29:55 -0000 (UTC) Organization: To protect and to server Message-ID: <vi6sb1$148h7$1@paganini.bofh.team> References: <vi54e9$3ie0o$1@dont-email.me> Injection-Date: Wed, 27 Nov 2024 10:29:55 -0000 (UTC) Injection-Info: paganini.bofh.team; logging-data="1188391"; posting-host="WwiNTD3IIceGeoS5hCc4+A.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A"; User-Agent: tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64)) X-Notice: Filtered by postfilter v. 0.9.3 Bytes: 2586 Lines: 49 Thiago Adams <thiago.adams@gmail.com> wrote: > > (I think I know the answer but I would like to learn more.) > > I am using C89 as "compiler backend intermediate language". > > I want a very simple output that could facilitate the construction of a > simple C89 compiler focused on code generation. > > I am removing these features from the generated code. > > - typedef > - enum > - preprocessor > - const > > > At this output, I am generating the prototypes for the functions I call. > > For instance, > int strcmp( const char* lhs, const char* rhs ); > > is generated as > > int strcmp( char* lhs, char* rhs ); > > I am also generating the structs as required (on demand). For the > structs I am renaming it because I am generating all structs at global > scope. > > Question: > Does the compiler/linkers? Cares If I am lying about const? Or If rename > the structs? 1) campilers for embedded targets care very much about const. const qualified arrays go into read-only data section which is typically located in flash. Other arrays go to RAM. Embedded targets frequently have very small RAM and larger flash, so after dropping const program may no longer fit in available RAM. 2) Linkers for non-standard formats may do whatever they please. In particular compiler could emit type information and linker may check it. 3) If you want later C, then C89 as intermediate format will not work, basically it is hard to implement VLA-s without VLA-s in target language. In principle you can replace VMT-s by pointer arithmetic, but then you have nontrivial chunk of code generator inside your front end. -- Waldek Hebisch