Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Why does C allow structs to have a tag? Date: Sat, 31 Jul 2021 16:25:19 -0700 Organization: None to speak of Lines: 76 Message-ID: <8735ruawww.fsf@nosuchdomain.example.com> References: <87zgu6f367.fsf@nosuchdomain.example.com> <87v94tg8sw.fsf@nosuchdomain.example.com> <87mtq5f92k.fsf@nosuchdomain.example.com> <20210730075445.167@kylheku.com> <878s1neknd.fsf@nosuchdomain.example.com> <875ywrctxg.fsf@nosuchdomain.example.com> <87wnp7bchb.fsf@nosuchdomain.example.com> <87bl6iazh8.fsf@nosuchdomain.example.com> <877dh6aylm.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="45c31737cfd44125daaf4223bdb9fd61"; logging-data="22209"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18j99/9/I7MpaUYXWoHGRkZ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:qG+QeUFKSfOeZBX4Ksfr+4yT9cY= sha1:qvvqyUrEV24avf02TRfPvSXmdww= Xref: csiph.com comp.lang.c:162179 Bart writes: > On 31/07/2021 23:48, Keith Thompson wrote: >> Keith Thompson writes: >>> [big snip] >>> >>> I've just installed TDM-GCC on my Windows 10 laptop. >> [big snip] >> I've just done a similar experiment with tcc, installed on Windows >> 10 >> from >> http://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27-win64-bin.zip >> There's a win32 installer as well. I didn't try it. >> Using the same program from my previous post and compiling with >> default >> options ("tcc c.c"), both "%zu" and "%Lg" work correctly. >> The lcc-generated executable is a "PE32+ executable (console) x86-64 >> (stripped to external PDB), for MS Windows". > > You mean tcc rather than lcc? Yes, thank you, that was a typo. > I downloaded this exact version with these results: > > -------------------------------------- > C:\tcc>dir > ... > 01/08/2021 00:08 . > 01/08/2021 00:08 .. > 01/08/2021 00:04 doc > 01/08/2021 00:04 examples > 31/07/2021 02:12 86 hello.c > 01/08/2021 00:06 2,048 hello.exe > 01/08/2021 00:04 155,136 i386-win32-tcc.exe > 01/08/2021 00:04 include > 01/08/2021 00:08 2,463 kkk1 > 01/08/2021 00:04 lib > 01/08/2021 00:04 libtcc > 01/08/2021 00:04 156,160 libtcc.dll > 01/08/2021 00:04 23,552 tcc.exe > ... > > C:\tcc>type hello.c > #include > int main(void) { > printf("Hello, World! %zu\n", sizeof(int)); > } > > C:\tcc>tcc hello.c > > C:\tcc>hello > Hello, World! zu > > > This was on Windows 7, but my last test on W10 didn't fix anything so > I doubt it would here. Results on your Windows 10 system could be interesting. > The EXE files shows it specifically imports printf() from msvcrt.dll OK, so it works correctly on my system but not on yours. I'll note that I've seen multiple versions of msvcrt.dll in different directories on my system (different sizes, different timestamps). Either my msvcrt.dll implements %zu correctly, or tcc and tdm-gcc generate executables that use something other than msvcrt.dll to implement printf. This discussion was triggered by your statement that %zu "doesn't work on Windows". It clearly does, though it might sometimes fail for reasons that are not clear. I do not expect you to acknowledge that your original statement was false. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */