Deutsch English Français Italiano |
<20250406210339.382@kylheku.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: "A diagram of C23 basic types" Date: Mon, 7 Apr 2025 04:09:54 -0000 (UTC) Organization: A noiseless patient Spider Lines: 52 Message-ID: <20250406210339.382@kylheku.com> References: <87y0wjaysg.fsf@gmail.com> <vsj1m8$1f8h2$1@dont-email.me> <vsj2l9$1j0as$1@dont-email.me> <vsjef3$1u4nk$1@dont-email.me> <vsjg6t$20pdb$1@dont-email.me> <vsjjd1$23ukt$1@dont-email.me> <vsjkvb$25mtg$1@dont-email.me> <vsjlkq$230a5$2@dont-email.me> <vsjs5k$2bfc5$2@dont-email.me> <vsjvgu$2fpp1$1@dont-email.me> <20250402113624.693@kylheku.com> <86o6xdhorr.fsf@linuxsc.com> <vsn0dm$2al86$1@paganini.bofh.team> <87ikngd7jg.fsf@nosuchdomain.example.com> Injection-Date: Mon, 07 Apr 2025 06:09:55 +0200 (CEST) Injection-Info: dont-email.me; posting-host="eb31c432c05cfae420ab44ef7470c62f"; logging-data="2980516"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pt1FTL3vy6LuLm5wB57WJZemoX9fc5a4=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:YMSDsZJMq3ptZpFNKlRRt/RyLuU= Bytes: 3216 On 2025-04-07, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > antispam@fricas.org (Waldek Hebisch) writes: >> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote: > [...] >>> Not always practical. A good example is the type size_t. If a >>> function takes an argument of type size_t, then the symbol size_t >>> should be defined, no matter which header the function is being >>> declared in. >> >> Why? One can use a type without a name for such type. > > Convenience and existing practice. Sure, an implementation of ><string.h> could provide a declaration of memcpy() without making > size_t visible, but what would be the point? Ther eis a point to such a discipline; you get ultra squeaky clean modules whose header files define only their contribution to the program, and do not transitively reveal any of the identifiers from their dependencies. In large programs, this clean practice can can help prevent clashes. Now memcpy is a bad example. But imagine some large API. Your program uses, say 5% of the API. Somewhere in the API is a utility function you're not interested in, It does something involving the API, and some type you don't care about. Why should the type be revealed to your translation unit? Using memcpy as an example, it could be declared as void *memcpy(void * restrict d, const void * restrict s, __size_t size); size_t is not revealed, but a private type __size_t. To get __size_t, some private header is included <sys/priv_types.h> or whatever. The <stddef.h> header just includes that one and typedefs __size_t size_t (if it were to work that way). A system vendor which provides many API's and has the privilege of being able to use the __* space could do things like this. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca