Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #103311
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Preprocessor expressions |
| Date | 2017-02-06 15:17 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <o7a3u7$9u$1@dont-email.me> (permalink) |
| References | (5 earlier) <634d154c-9d22-4a83-8d3c-85ca4b89ae06@googlegroups.com> <mGKkA.214862$3L.178811@fx26.am4> <e3c53979-10e8-44e4-b6c4-0cd5b65ae78f@googlegroups.com> <4bb1dbcd-6e3c-40df-8319-eb33b8bfa685@googlegroups.com> <030e3613-d745-46c4-8a46-d625eb276baa@googlegroups.com> |
On 05/02/2017 19:03, Thiago Adams wrote:
> In a different approach where the source is not intended to
> be read (at least all the time) I think the best solution
> is to ignore pre-processor and generate code direct from AST.
> So, if you change #if macros you need to re-generate everything
> from the original source.
> Using this approach we also need to decide if the system includes
> will be added or not. System includes or "extern C" code could be
> the exception to the rule and they could be added at the top of the
> translation unit.
>
> //Begin external code includes
> #include <stdio.h>
> #include <some_c_lib.h>
> //End external code includes
With a translator with C output, the possibilities for dealing with
<stdio.h> for example are:
* Write #include <stdio.h> to the output too
* Write a preprocessed version of stdio.h
However that can result in user-code being dominated by preprocessed
versions of the standard headers. (It won't be the nearly 5000 lines
that are involved with stdio.h from gcc, but a few hundred as
conditional code is excluded, so still quite a bit.)
One idea I might try out, is to only output declarations from stdio.h
that are used in the program (either directly on indirectly). For
hello.c, that means declaring printf().
But the user program can still have this:
#if cond
printf("hello");
#endif
For my purposes, everything will need to be preprocessed anyway, so
printf will be included when cond is true. The output will be C code
that doesn't use any headers, not even system ones.
--
bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Preprocessor expressions BartC <bc@freeuk.com> - 2017-01-22 13:24 +0000
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-01-22 07:52 -0800
Re: Preprocessor expressions Ralf Damaschke <rwspam@gmx.de> - 2017-01-22 17:15 +0000
Re: Preprocessor expressions "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-22 13:32 -0500
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-01-22 17:38 +0000
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-01 03:12 -0800
Re: Preprocessor expressions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-01 11:44 +0000
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-01 11:56 +0000
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-02-01 08:35 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-02 09:23 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-02 18:14 +0000
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-02 10:35 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-02 17:09 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-05 10:09 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-05 10:38 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-05 11:03 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-06 15:17 +0000
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-07 05:36 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-07 21:01 +0000
Re: Preprocessor expressions supercat@casperkitty.com - 2017-02-07 13:16 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-07 22:09 +0000
Re: Preprocessor expressions supercat@casperkitty.com - 2017-02-07 14:33 -0800
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-07 14:52 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-08 00:13 +0000
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-07 16:39 -0800
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-02-07 16:47 -0800
Re: Preprocessor expressions David Brown <david.brown@hesbynett.no> - 2017-02-08 10:03 +0100
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-08 09:19 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-08 12:35 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-09 05:25 -0800
Re: Preprocessor expressions supercat@casperkitty.com - 2017-02-09 07:37 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-09 15:52 +0000
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-01-22 19:34 +0000
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-01-22 13:01 -0800
Re: Preprocessor expressions Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 05:30 -0800
csiph-web