Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams Newsgroups: comp.lang.c Subject: Re: transpiling to low level C Date: Sun, 15 Dec 2024 09:13:41 -0300 Organization: A noiseless patient Spider Lines: 45 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 15 Dec 2024 13:13:42 +0100 (CET) Injection-Info: dont-email.me; posting-host="75cbf010cfc8fccc260a6c4cc0d7f911"; logging-data="574977"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xmqycqsNWBenXEtC2GVbwhvcdMN65wYg=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:1Nw0eQSXUAsF7i5yeTj78bzk/Js= In-Reply-To: Content-Language: en-GB Bytes: 2439 Em 12/15/2024 8:46 AM, Thiago Adams escreveu: > Em 12/15/2024 8:28 AM, bart escreveu: >> On 15/12/2024 03:05, Thiago Adams wrote: >>> >>> I am working on a C backend that generates simple C code. >>> >>> You can test it here: >>> http://thradams.com/cake/playground.html >>> >>> Objective >>> - Shift all the complexity of the C compiler to the frontend. >>>    Why? This approach simplifies having one frontend and multiple >>> backends. >>> - Use C as an intermediate language to feed a backend (any C compiler >>> can act as the backend). >>>    The backend can then focus solely on code generation. >>> - Code is not portable >>> >>> Removed C89 Features >>> - Preprocessor >>> - sizeof >> >> If I try: >> >>      printf("%zu\n", sizeof(void*)); >> >> it turns into: >> >>      printf("%zu\n", 4U); >> >> Presumably this translator will only target 32-bit systems even if run >> on a 64-bit one? >> > > It will have to be configured to x86 or x64. It has to match the target/ > platform compiler settings. The online versions is emulating something. > I think x86 gcc on linux. > Th Obs: The platform windows\linux makes difference in the size of wchar_t L'a' also on sizes of long etc.. In practice the result is assuming fixed sizes. I may add at the end of generated code the assumptions . It can be in a static_assert form.