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: Thu, 29 Jul 2021 12:43:54 -0700 Organization: None to speak of Lines: 87 Message-ID: <875ywsgb2d.fsf@nosuchdomain.example.com> References: <87sfzzgr72.fsf@nosuchdomain.example.com> <1mgMI.17475$6j.16299@fx04.iad> <87zgu6f367.fsf@nosuchdomain.example.com> <87v94tg8sw.fsf@nosuchdomain.example.com> <87mtq5f92k.fsf@nosuchdomain.example.com> <87im0tf2rn.fsf@nosuchdomain.example.com> <87a6m5f0j9.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="f7dbd806dd1436700e4487cff600874e"; logging-data="13825"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k+/Pz6DW523xlBGHfxJlr" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:4H169DCli6z6FG/yJRMwNeT7GwE= sha1:6UtDswyrwRszS0aBWI6UUEpnBmk= Xref: csiph.com comp.lang.c:162103 Bart writes: > On 29/07/2021 19:16, Keith Thompson wrote: >> Bart writes: >>> On 29/07/2021 18:28, Keith Thompson wrote: >>>> Bart writes: >>>>> This program: >>>>> >>>>> #include >>>>> int main(void) {printf("%zu\n",sizeof(void*));} >>>>> >>>>> displays 'zu' with gcc, tcc and bcc (my product that uses msvcrt.dll). >>> >>>> The problem is with the old C library. The version of gcc is >>>> irrelevant. >>>> Windows 7 is obsolete. If you're stuck using it for some reason, >>>> that's >>>> a valid reason to avoid "%zu". "it doesn't work on Windows" is not. >>> >>> Looks like Windows 10 is obsolete too: >>> >>> c:\c>ver >>> Microsoft Windows [Version 10.0.14393] >>> >>> c:\c>type c.c >>> #include >>> >>> int main(void) { >>> printf("%zu\n", sizeof(void*)); >>> } >>> >>> c:\c>gcc c.c >>> >>> c:\c>a >>> zu >> No, it looks like you're using an obsolete C library implementation >> on >> Windows 10. > > You said 'Windows 7 is obsolete'. I did, and it is. > Anyway, how can the C library be obsolete if it comes /with/ Windows > 10? Even if I could, installing a different library wouldn't be much > help, since then I'd have programs that worked fine on my Windows, but > on no one else's unless they jumped through the same hoops. I don't know enough about it to answer that. I use Visual Studio for work and Cygwin for personal use. I don't have a gcc-based implementation outside Cygwin. Microsoft's online documentation says "%zu" works. I know that Microsoft was very slow to support C99 (which is where %zu was introduced), but they've made considerable progress more recently. > Just for the sake of %zu which can be trivially replaced with %d and a > (int) cast (or %lld and (long long) if expecting some big objects), it > is not worth the headache of extra dependencies. On the systems and implementions I currently use, there are no extra dependencies; "%zu" just works, and I don't seem to have an implementation where it doesn't. For my own purposes, I have no reason to avoid "%zu". Obviously your situation is different, and there are several workarounds you can use. I don't know what C library implementation you're using or how it was installed, other than your statement that it came with Windows 10. If you're not bothered by its lack of support for "%zu", I don't see anything more to discuss. >> I'm able to compile and run your program on Windows 10, >> and it prints 8 or 4 depending on which implementation I use. >> You could probably get some help with that if you asked (and >> provided >> some information). > > Does Tiny C work too? I don't have Tiny C on either Windows 10 system I have access to, but I presume it would use the same library that gcc uses, so I'd expect it to work. (tcc, like gcc, is a compiler, not a complete implementation. You have a habit of glossing over that.) -- 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 */