Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All your files have been destroyed (sorry). Paul.


devel / comp.lang.c / Re: Why does C allow structs to have a tag?

SubjectAuthor
* Why does C allow structs to have a tag?James Harris
+* Re: Why does C allow structs to have a tag?David Brown
|`* Re: Why does C allow structs to have a tag?Thiago Adams
| `- Re: Why does C allow structs to have a tag?David Brown
+- Re: Why does C allow structs to have a tag?Öö Tiib
+* Re: Why does C allow structs to have a tag?Bart
|+* Re: Why does C allow structs to have a tag?Kaz Kylheku
||+- Re: Why does C allow structs to have a tag?Bart
||`* Re: Why does C allow structs to have a tag?Manfred
|| `* Re: Why does C allow structs to have a tag?David Brown
||  `* Re: Why does C allow structs to have a tag?Bart
||   +- Re: Why does C allow structs to have a tag?Richard Harnden
||   +* Re: Why does C allow structs to have a tag?Keith Thompson
||   |+* Re: Why does C allow structs to have a tag?Bart
||   ||+- Re: Why does C allow structs to have a tag?Keith Thompson
||   ||`* Re: Why does C allow structs to have a tag?James Harris
||   || `- Re: Why does C allow structs to have a tag?Bart
||   |`* Re: Why does C allow structs to have a tag?Manfred
||   | `* Re: Why does C allow structs to have a tag?Keith Thompson
||   |  `* Re: Why does C allow structs to have a tag?Bart
||   |   +* Re: Why does C allow structs to have a tag?David Brown
||   |   |`- Re: Why does C allow structs to have a tag?Bart
||   |   `* Re: Why does C allow structs to have a tag?Keith Thompson
||   |    `- Re: Why does C allow structs to have a tag?Malcolm McLean
||   `* Re: Why does C allow structs to have a tag?David Brown
||    `* Re: Why does C allow structs to have a tag?Bart
||     +* Re: Why does C allow structs to have a tag?David Brown
||     |`* Re: Why does C allow structs to have a tag?Bart
||     | `* Re: Why does C allow structs to have a tag?Malcolm McLean
||     |  `* Re: Why does C allow structs to have a tag?Bart
||     |   `* Re: Why does C allow structs to have a tag?Kaz Kylheku
||     |    `* Re: Why does C allow structs to have a tag?Bart
||     |     +- Re: Why does C allow structs to have a tag?James Harris
||     |     `* Re: Why does C allow structs to have a tag?Kaz Kylheku
||     |      `* Re: Why does C allow structs to have a tag?Bart
||     |       `* Re: Why does C allow structs to have a tag?Keith Thompson
||     |        `* Re: Why does C allow structs to have a tag?Bart
||     |         `- Re: Why does C allow structs to have a tag?Keith Thompson
||     `* Re: Why does C allow structs to have a tag?James Harris
||      `- Re: Why does C allow structs to have a tag?Bart
|`- Re: Why does C allow structs to have a tag?Keith Thompson
+* Re: Why does C allow structs to have a tag?Kaz Kylheku
|`* Re: Why does C allow structs to have a tag?Bart
| `- Re: Why does C allow structs to have a tag?James Harris
+- Re: Why does C allow structs to have a tag?James Kuyper
+* Re: Why does C allow structs to have a tag?Richard Damon
|`- Re: Why does C allow structs to have a tag?James Harris
+* Re: Why does C allow structs to have a tag?Joe Pfeiffer
|`* Re: Why does C allow structs to have a tag?Malcolm McLean
| +* Re: Why does C allow structs to have a tag?Guillaume
| |+* Re: Why does C allow structs to have a tag?Kaz Kylheku
| ||`* Re: Why does C allow structs to have a tag?Bart
| || `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| ||  `* Re: Why does C allow structs to have a tag?Bart
| ||   `- Re: Why does C allow structs to have a tag?Keith Thompson
| |`* Re: Why does C allow structs to have a tag?James Kuyper
| | `* Re: Why does C allow structs to have a tag?Bart
| |  `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   +* Re: Why does C allow structs to have a tag?Bart
| |   |`* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   | `* Re: Why does C allow structs to have a tag?Bart
| |   |  `* Re: Why does C allow structs to have a tag?David Brown
| |   |   `* Re: Why does C allow structs to have a tag?Bart
| |   |    +* Re: Why does C allow structs to have a tag?David Brown
| |   |    |`* Re: Why does C allow structs to have a tag?Bart
| |   |    | `* Re: Why does C allow structs to have a tag?David Brown
| |   |    |  +* Re: Why does C allow structs to have a tag?Manfred
| |   |    |  |`- Re: Why does C allow structs to have a tag?David Brown
| |   |    |  +- Re: Why does C allow structs to have a tag?Bart
| |   |    |  `* Re: Why does C allow structs to have a tag?Bart
| |   |    |   +- Re: Why does C allow structs to have a tag?David Brown
| |   |    |   `* Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    +* Re: Why does C allow structs to have a tag?Guillaume
| |   |    |    |+* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |    ||`- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |+- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |+- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |`- Re: Why does C allow structs to have a tag?David Brown
| |   |    |    `* Re: Why does C allow structs to have a tag?Bart
| |   |    |     `* Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |      `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       +* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |`* Re: Why does C allow structs to have a tag?Ben Bacarisse
| |   |    |       | `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |  `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |   `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |    +* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |    |`* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |    | `- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |       |    `- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |       `- Re: Why does C allow structs to have a tag?David Brown
| |   |    `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |     `* Re: Why does C allow structs to have a tag?Bart
| |   |      `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |       `- Re: Why does C allow structs to have a tag?Bart
| |   `* Re: Why does C allow structs to have a tag?Bart
| |    +- Re: Why does C allow structs to have a tag?Keith Thompson
| |    `- Re: Why does C allow structs to have a tag?Kaz Kylheku
| +* Re: Why does C allow structs to have a tag?Joe Pfeiffer
| |`- Re: Why does C allow structs to have a tag?Kaz Kylheku
| `- Re: Why does C allow structs to have a tag?Richard Damon
+* Re: Why does C allow structs to have a tag?John Bode
+- Re: Why does C allow structs to have a tag?Siri Cruise
`* Re: Why does C allow structs to have a tag?Andrey Tarasevich

Pages:12345678910111213141516
Re: Why does C allow structs to have a tag?

<b7491e5f-66f9-427b-a738-87b99980abe5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17670&group=comp.lang.c#17670

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:5cee:: with SMTP id iv14mr5154413qvb.33.1627564186398;
Thu, 29 Jul 2021 06:09:46 -0700 (PDT)
X-Received: by 2002:a05:6214:d1:: with SMTP id f17mr5180349qvs.12.1627564186250;
Thu, 29 Jul 2021 06:09:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 29 Jul 2021 06:09:46 -0700 (PDT)
In-Reply-To: <87v94tg8sw.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=160.107.87.10; posting-account=rH_E3woAAADR_9M5Q9bWAyDPjAMcf7LJ
NNTP-Posting-Host: 160.107.87.10
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
<20210727083246.384@kylheku.com> <87h7gfiqu0.fsf@nosuchdomain.example.com>
<sdpuui$1c0v$1@gioia.aioe.org> <Tw%LI.6384$XI4.2315@fx09.iad>
<sdq5e2$e4v$1@dont-email.me> <87sfzzgr72.fsf@nosuchdomain.example.com>
<GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me>
<nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me>
<1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me>
<87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b7491e5f-66f9-427b-a738-87b99980abe5n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: jadil...@gmail.com (John Dill)
Injection-Date: Thu, 29 Jul 2021 13:09:46 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4636
 by: John Dill - Thu, 29 Jul 2021 13:09 UTC

On Wednesday, July 28, 2021 at 10:20:43 PM UTC-4, Keith Thompson wrote:
> Bart <b...@freeuk.com> writes:
> > On 29/07/2021 00:07, Keith Thompson wrote:
> >> Bart <b...@freeuk.com> writes:
> >>> On 28/07/2021 18:21, Scott Lurndal wrote:
> >>>> Bart <b...@freeuk.com> writes:
> >> [...]
> >>
> >>> I want to call a C function via an FFI from a language that I've
> >>> devised. The public API says one parameter type is off_t.
> >>>
> >>> Which type matches that in my language? I have to choose from i8-i64
> >>> and u8-u64.
> >>>
> >>> The kind of answer I want is (a) 'It uses i64' etc; or (b) 'It uses
> >>> i32 or u64 depending on platform'.
> >> POSIX says that off_t is a signed integer type.
> >> Is there some reason that compiling and running this program on the
> >> target system doesn't solve your problem?
> >> #include <stdio.h>
> >> #include <limits.h>
> >> int main(void) {
> >> printf("off_t is %c%zu\n",
> >> (off_t)-1 < (off_t)0 ? 'i' : 'u',
> >> CHAR_BIT * sizeof (off_t));
> >> }
> >
> > Sure, I can do that (after fixing the code with the right includes and
> > avoiding %zu). But that's the trial and error approach.
> %zu is the correct format specifier. I'm not even going to ask why
> you'd want to avoid it.
>
> Yes, I probably should have used `#include <sys/types.h>`.
>
> No, it's not trial and error. Write the program once, compile and run
> it on each platform of interest. Expand the program as needed to show
> the characteristcs of all the types you're interested in. Tweak the
> output any way you like to suit your purposes. Make it generate source
> code in your personal language if you like.
> > In the end I might end up with a list of such types for my platform,
> > and what concrete types they actually are.
> >
> > But, why doesn't such a list already exist anyway? It's not as though
> > my platform is a rare, obscure one out of hundreds; it's Windows on
> > x64. The other two I might be interested in are Linux on x64 and on
> > arm64.
> Such a list might exist somewhere. If it doesn't, or if it's hard to
> find, it's probably because not many people are interested in it.
>
> And I've just shown you how you can generate such a list yourself, by
> writing a C program that generates it.
>
> [snip]
>
> (I didn't look at the Fortran stuff.)

This is kind of what build systems are for, even though it doesn't suit
Bart's tastes. To find the size of an opaque type, you'd leverage something
similar to ac_check_sizeof from autoconf that basically generates a C
program, runs the program, inspects the stdout, stderr or return code, then
sets a define in a config.h style file based on the result.

Bart could even do his own mini home-grown version of that if he had
the motivation. You just need some kind of scripting language that can
interact with the shell.

Re: Why does C allow structs to have a tag?

<sduab9$1le$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17671&group=comp.lang.c#17671

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 14:26:53 +0100
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <sduab9$1le$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<b7491e5f-66f9-427b-a738-87b99980abe5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Jul 2021 13:27:05 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="aa2fadcab57ffd4f2499933de6d02d17";
logging-data="1710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EyUrB8Z8+gJRGgj2LmQyoB9Iv5YbITNE="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:AGTCj5oqCLE2i1oxd91YC62Hieo=
In-Reply-To: <b7491e5f-66f9-427b-a738-87b99980abe5n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210729-0, 29/7/2021), Outbound message
 by: Bart - Thu, 29 Jul 2021 13:26 UTC

On 29/07/2021 14:09, John Dill wrote:
> On Wednesday, July 28, 2021 at 10:20:43 PM UTC-4, Keith Thompson wrote:
>> Bart <b...@freeuk.com> writes:
>>> On 29/07/2021 00:07, Keith Thompson wrote:
>>>> Bart <b...@freeuk.com> writes:
>>>>> On 28/07/2021 18:21, Scott Lurndal wrote:
>>>>>> Bart <b...@freeuk.com> writes:
>>>> [...]
>>>>
>>>>> I want to call a C function via an FFI from a language that I've
>>>>> devised. The public API says one parameter type is off_t.
>>>>>
>>>>> Which type matches that in my language? I have to choose from i8-i64
>>>>> and u8-u64.
>>>>>
>>>>> The kind of answer I want is (a) 'It uses i64' etc; or (b) 'It uses
>>>>> i32 or u64 depending on platform'.
>>>> POSIX says that off_t is a signed integer type.
>>>> Is there some reason that compiling and running this program on the
>>>> target system doesn't solve your problem?
>>>> #include <stdio.h>
>>>> #include <limits.h>
>>>> int main(void) {
>>>> printf("off_t is %c%zu\n",
>>>> (off_t)-1 < (off_t)0 ? 'i' : 'u',
>>>> CHAR_BIT * sizeof (off_t));
>>>> }
>>>
>>> Sure, I can do that (after fixing the code with the right includes and
>>> avoiding %zu). But that's the trial and error approach.
>> %zu is the correct format specifier. I'm not even going to ask why
>> you'd want to avoid it.
>>
>> Yes, I probably should have used `#include <sys/types.h>`.
>>
>> No, it's not trial and error. Write the program once, compile and run
>> it on each platform of interest. Expand the program as needed to show
>> the characteristcs of all the types you're interested in. Tweak the
>> output any way you like to suit your purposes. Make it generate source
>> code in your personal language if you like.
>>> In the end I might end up with a list of such types for my platform,
>>> and what concrete types they actually are.
>>>
>>> But, why doesn't such a list already exist anyway? It's not as though
>>> my platform is a rare, obscure one out of hundreds; it's Windows on
>>> x64. The other two I might be interested in are Linux on x64 and on
>>> arm64.
>> Such a list might exist somewhere. If it doesn't, or if it's hard to
>> find, it's probably because not many people are interested in it.
>>
>> And I've just shown you how you can generate such a list yourself, by
>> writing a C program that generates it.
>>
>> [snip]
>>
>> (I didn't look at the Fortran stuff.)
>
> This is kind of what build systems are for, even though it doesn't suit
> Bart's tastes. To find the size of an opaque type, you'd leverage something
> similar to ac_check_sizeof from autoconf that basically generates a C
> program, runs the program, inspects the stdout, stderr or return code, then
> sets a define in a config.h style file based on the result.
>
> Bart could even do his own mini home-grown version of that if he had
> the motivation. You just need some kind of scripting language that can
> interact with the shell.
>

People seem to be missing the point. You shouldn't NEED to write
scripts, install a C compiler, write test programs just to find out what
a type is! They shouldn't work as hard as they do to hide these types.

For goodness sake, an offset type is either going to be i32 or i64!

Look at my link to Windows data types, where all the info needed is on
that one web-page.

Re: Why does C allow structs to have a tag?

<JnyMI.95667$Vv6.47715@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17672&group=comp.lang.c#17672

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <sdq5e2$e4v$1@dont-email.me> <87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com> <b7491e5f-66f9-427b-a738-87b99980abe5n@googlegroups.com> <sduab9$1le$1@dont-email.me>
Lines: 22
Message-ID: <JnyMI.95667$Vv6.47715@fx45.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Jul 2021 13:51:37 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Jul 2021 13:51:37 GMT
X-Received-Bytes: 1950
 by: Scott Lurndal - Thu, 29 Jul 2021 13:51 UTC

Bart <bc@freeuk.com> writes:
>On 29/07/2021 14:09, John Dill wrote:

>>
>> Bart could even do his own mini home-grown version of that if he had
>> the motivation. You just need some kind of scripting language that can
>> interact with the shell.
>>
>
>People seem to be missing the point. You shouldn't NEED to write
>scripts, install a C compiler, write test programs just to find out what
>a type is! They shouldn't work as hard as they do to hide these types.

No, you're missing the point. 99.9999% of people writing code
in the C language don't need to know what the underlying type is. Noting
that it (off_t for example) is a signed integer is all they need
to know.

>
>For goodness sake, an offset type is either going to be i32 or i64!

No, it's not. C runs on many platforms other than Windows on x86.

Re: Why does C allow structs to have a tag?

<87mtq5f92k.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17673&group=comp.lang.c#17673

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 08:12:19 -0700
Organization: None to speak of
Lines: 20
Message-ID: <87mtq5f92k.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com>
<sdpuui$1c0v$1@gioia.aioe.org> <Tw%LI.6384$XI4.2315@fx09.iad>
<sdq5e2$e4v$1@dont-email.me> <87sfzzgr72.fsf@nosuchdomain.example.com>
<GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me>
<nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me>
<1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me>
<87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me>
<87v94tg8sw.fsf@nosuchdomain.example.com> <sdtugu$an9$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f7dbd806dd1436700e4487cff600874e";
logging-data="18668"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oGV7D0uSExWDKpINylFXB"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:1yUoLM5VxDZOyWjMwPHCpZNcyVU=
sha1:dDmALQDeryvbKlvtRiZs0ugUk2c=
 by: Keith Thompson - Thu, 29 Jul 2021 15:12 UTC

Bart <bc@freeuk.com> writes:
> On 29/07/2021 03:20, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
[...]
>>> Sure, I can do that (after fixing the code with the right includes and
>>> avoiding %zu). But that's the trial and error approach.
>> %zu is the correct format specifier. I'm not even going to ask why
>> you'd want to avoid it.
>
> I'll tell you anyway: it doesn't work on Windows.

Yes, it does. I don't know why it wouldn't work for you. Are you using
some obsolete version of Windows or of its C implementation?

[...]

--
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 */

Re: Why does C allow structs to have a tag?

<sdugt4$ncj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17674&group=comp.lang.c#17674

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 16:18:50 +0100
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <sdugt4$ncj$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<b7491e5f-66f9-427b-a738-87b99980abe5n@googlegroups.com>
<sduab9$1le$1@dont-email.me> <JnyMI.95667$Vv6.47715@fx45.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Jul 2021 15:19:01 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="aa2fadcab57ffd4f2499933de6d02d17";
logging-data="23955"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OuLxZ6RvQF36U9Hw4hSowh8W6kjjWYOE="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:s05kHph3bIi4xkkiS3v1ciSMvlI=
In-Reply-To: <JnyMI.95667$Vv6.47715@fx45.iad>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210729-0, 29/7/2021), Outbound message
 by: Bart - Thu, 29 Jul 2021 15:18 UTC

On 29/07/2021 14:51, Scott Lurndal wrote:
> Bart <bc@freeuk.com> writes:
>> On 29/07/2021 14:09, John Dill wrote:
>
>>>
>>> Bart could even do his own mini home-grown version of that if he had
>>> the motivation. You just need some kind of scripting language that can
>>> interact with the shell.
>>>
>>
>> People seem to be missing the point. You shouldn't NEED to write
>> scripts, install a C compiler, write test programs just to find out what
>> a type is! They shouldn't work as hard as they do to hide these types.
>
> No, you're missing the point. 99.9999% of people writing code
> in the C language don't need to know what the underlying type is. Noting
> that it (off_t for example) is a signed integer is all they need
> to know.
>
>>
>> For goodness sake, an offset type is either going to be i32 or i64!
>
> No, it's not. C runs on many platforms other than Windows on x86.
>

You have a small point, but mainly you're just making excuses for some
terrible header code that should long have been cleaned up.

The _mingw_off_t.h file I posted that makes such a meal of defining
off_t, is specifically for Windows on x86.

I would also suggest that those languages that would like to use C
libraries, the ones that predominantly use integer types based around
8/16/32/64 bits, will not be running on the same 13-bit processors that
C likes to support.

They are also unlikely to run under a system where a file offset of 16
bits is sufficient (that would be too small even for a 1980s floppy
disk). The most useful type these days would be i64.

I actually haven't used fstat(), if that's what's it's called, for
perhaps 20 years. There are two many myriad combinations of it with the
numerous variations of struct stat, off_t and the rest.

There are 8 combinations listed here (6 functions plus file length
variations, halfway down the page):

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/fstat-fstat32-fstat64-fstati64-fstat32i64-fstat64i32?view=msvc-160

Another page lists TWELVE versions of struct stat (6 using char* plus 6
with wchar_t*).

This is for basically two platforms (Win32 and Win64), but they will run
under the same file system that will have files bigger than 2GB, so
you'd expect the same file functions and associated types for both.

I would call that messy, and that's without even delving into the headers.

Re: Why does C allow structs to have a tag?

<sduhq4$3ll$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17675&group=comp.lang.c#17675

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 16:34:23 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <sduhq4$3ll$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Jul 2021 15:34:28 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="aa2fadcab57ffd4f2499933de6d02d17";
logging-data="3765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/SYuKMydZKZVMEyleS/zm2/1cG21eyPpc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:y8fsWcoj0j7EWc5SgyUoDSRpcWc=
In-Reply-To: <87mtq5f92k.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210729-0, 29/7/2021), Outbound message
 by: Bart - Thu, 29 Jul 2021 15:34 UTC

On 29/07/2021 16:12, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
>> On 29/07/2021 03:20, Keith Thompson wrote:
>>> Bart <bc@freeuk.com> writes:
> [...]
>>>> Sure, I can do that (after fixing the code with the right includes and
>>>> avoiding %zu). But that's the trial and error approach.
>>> %zu is the correct format specifier. I'm not even going to ask why
>>> you'd want to avoid it.
>>
>> I'll tell you anyway: it doesn't work on Windows.
>
> Yes, it does. I don't know why it wouldn't work for you. Are you using
> some obsolete version of Windows or of its C implementation?

It's Windows 7. gcc is version 9.2.0.

This program:

#include <stdio.h>
int main(void) {printf("%zu\n",sizeof(void*));}

displays 'zu' with gcc, tcc and bcc (my product that uses msvcrt.dll).

It shows the correct value with lccwin, DMC, clang and CL (MS' compiler).

Since I predominantly use the first 3 compilers, I don't find zu useful.

Actually until I did this test, I couldn't remember which supported it
and which didn't. I like code that works on anything, so prefer to use a
format supported on any compiler.

Maybe there is a way of persuading gcc to use better libraries, but I've
no idea how, and anyway like to run it like this:

gcc prog.c

If this a program that will only be used with bcc, then there I can use
"%?", which is replaced with the correct format, I believe "%llu" here,
and get the right answer as well. That would have been a more useful
extension than another bizarre and very specific format.

Re: Why does C allow structs to have a tag?

<MhBMI.30408$bR5.466@fx44.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17678&group=comp.lang.c#17678

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx44.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <sdq5e2$e4v$1@dont-email.me> <87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com> <sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com> <sduhq4$3ll$1@dont-email.me>
Lines: 39
Message-ID: <MhBMI.30408$bR5.466@fx44.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 29 Jul 2021 17:10:04 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 29 Jul 2021 17:10:04 GMT
X-Received-Bytes: 2434
 by: Scott Lurndal - Thu, 29 Jul 2021 17:10 UTC

Bart <bc@freeuk.com> writes:
>On 29/07/2021 16:12, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> On 29/07/2021 03:20, Keith Thompson wrote:
>>>> Bart <bc@freeuk.com> writes:
>> [...]
>>>>> Sure, I can do that (after fixing the code with the right includes and
>>>>> avoiding %zu). But that's the trial and error approach.
>>>> %zu is the correct format specifier. I'm not even going to ask why
>>>> you'd want to avoid it.
>>>
>>> I'll tell you anyway: it doesn't work on Windows.
>>
>> Yes, it does. I don't know why it wouldn't work for you. Are you using
>> some obsolete version of Windows or of its C implementation?
>
>It's Windows 7. gcc is version 9.2.0.
>
>This program:
>
> #include <stdio.h>
> int main(void) {printf("%zu\n",sizeof(void*));}

It has _always_ worked properly with GCC. You're clearly
either doing something incorrect if your assertion is accurate.

$ cc -o /tmp/b /tmp/b.c
$ /tmp/b
8 $ cat /tmp/b.c
#include <stdio.h>
int main(void) {printf("%zu\n",sizeof(void*));}
$ cc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Re: Why does C allow structs to have a tag?

<87im0tf2rn.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17679&group=comp.lang.c#17679

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 10:28:28 -0700
Organization: None to speak of
Lines: 53
Message-ID: <87im0tf2rn.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com>
<sdpuui$1c0v$1@gioia.aioe.org> <Tw%LI.6384$XI4.2315@fx09.iad>
<sdq5e2$e4v$1@dont-email.me> <87sfzzgr72.fsf@nosuchdomain.example.com>
<GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me>
<nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me>
<1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me>
<87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me>
<87v94tg8sw.fsf@nosuchdomain.example.com> <sdtugu$an9$1@dont-email.me>
<87mtq5f92k.fsf@nosuchdomain.example.com> <sduhq4$3ll$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f7dbd806dd1436700e4487cff600874e";
logging-data="18257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185KcPGysPof1dPQKUWCxWf"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:IIqsEskg6st14d/qtgUyd2afNLs=
sha1:dBhmIyZbbXSmdaikZFcVbrKAO34=
 by: Keith Thompson - Thu, 29 Jul 2021 17:28 UTC

Bart <bc@freeuk.com> writes:
> On 29/07/2021 16:12, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> On 29/07/2021 03:20, Keith Thompson wrote:
>>>> Bart <bc@freeuk.com> writes:
>> [...]
>>>>> Sure, I can do that (after fixing the code with the right includes and
>>>>> avoiding %zu). But that's the trial and error approach.
>>>> %zu is the correct format specifier. I'm not even going to ask why
>>>> you'd want to avoid it.
>>>
>>> I'll tell you anyway: it doesn't work on Windows.
>> Yes, it does. I don't know why it wouldn't work for you. Are you
>> using
>> some obsolete version of Windows or of its C implementation?
>
> It's Windows 7. gcc is version 9.2.0.
>
> This program:
>
> #include <stdio.h>
> int main(void) {printf("%zu\n",sizeof(void*));}
>
> displays 'zu' with gcc, tcc and bcc (my product that uses msvcrt.dll).
>
> It shows the correct value with lccwin, DMC, clang and CL (MS' compiler).
>
> Since I predominantly use the first 3 compilers, I don't find zu useful.
>
> Actually until I did this test, I couldn't remember which supported it
> and which didn't. I like code that works on anything, so prefer to use
> a format supported on any compiler.
>
> Maybe there is a way of persuading gcc to use better libraries, but
> I've no idea how, and anyway like to run it like this:
>
> gcc prog.c
>
> If this a program that will only be used with bcc, then there I can
> use "%?", which is replaced with the correct format, I believe "%llu"
> here, and get the right answer as well. That would have been a more
> useful extension than another bizarre and very specific format.

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.

--
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 */

Re: Why does C allow structs to have a tag?

<87eebhf2pe.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17680&group=comp.lang.c#17680

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 10:29:49 -0700
Organization: None to speak of
Lines: 36
Message-ID: <87eebhf2pe.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com>
<GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me>
<nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me>
<1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me>
<87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me>
<87v94tg8sw.fsf@nosuchdomain.example.com> <sdtugu$an9$1@dont-email.me>
<87mtq5f92k.fsf@nosuchdomain.example.com> <sduhq4$3ll$1@dont-email.me>
<MhBMI.30408$bR5.466@fx44.iad>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f7dbd806dd1436700e4487cff600874e";
logging-data="18257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XVysG3AxiftKwySKzx+6F"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:KsHCn/l+zP/wrxKCTjg40D9mvSE=
sha1:+kX2kv+18lAkc3IDRLqxSMvm8l8=
 by: Keith Thompson - Thu, 29 Jul 2021 17:29 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> Bart <bc@freeuk.com> writes:
>>On 29/07/2021 16:12, Keith Thompson wrote:
>>> Bart <bc@freeuk.com> writes:
>>>> On 29/07/2021 03:20, Keith Thompson wrote:
>>>>> Bart <bc@freeuk.com> writes:
>>> [...]
>>>>>> Sure, I can do that (after fixing the code with the right includes and
>>>>>> avoiding %zu). But that's the trial and error approach.
>>>>> %zu is the correct format specifier. I'm not even going to ask why
>>>>> you'd want to avoid it.
>>>>
>>>> I'll tell you anyway: it doesn't work on Windows.
>>>
>>> Yes, it does. I don't know why it wouldn't work for you. Are you using
>>> some obsolete version of Windows or of its C implementation?
>>
>>It's Windows 7. gcc is version 9.2.0.
>>
>>This program:
>>
>> #include <stdio.h>
>> int main(void) {printf("%zu\n",sizeof(void*));}
>
> It has _always_ worked properly with GCC. You're clearly
> either doing something incorrect if your assertion is accurate.

[...]

gcc doesn't implement printf. The C library does. Bart is using an
obsolete version of Microsoft's C library.

--
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 */

Re: Why does C allow structs to have a tag?

<sduqoh$np9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17681&group=comp.lang.c#17681

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 19:07:07 +0100
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <sduqoh$np9$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me> <87im0tf2rn.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Jul 2021 18:07:13 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="aa2fadcab57ffd4f2499933de6d02d17";
logging-data="24361"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/78Z8tsuDlg98qtylY86gH7UCze4NPG2g="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:J0J8dVIeofoP02z4TBuivPVaPHA=
In-Reply-To: <87im0tf2rn.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210729-0, 29/7/2021), Outbound message
 by: Bart - Thu, 29 Jul 2021 18:07 UTC

On 29/07/2021 18:28, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:

>> This program:
>>
>> #include <stdio.h>
>> 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 <stdio.h>

int main(void) {
printf("%zu\n", sizeof(void*));
}

c:\c>gcc c.c

c:\c>a
zu

Re: Why does C allow structs to have a tag?

<87a6m5f0j9.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17682&group=comp.lang.c#17682

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 11:16:42 -0700
Organization: None to speak of
Lines: 44
Message-ID: <87a6m5f0j9.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com>
<sdpuui$1c0v$1@gioia.aioe.org> <Tw%LI.6384$XI4.2315@fx09.iad>
<sdq5e2$e4v$1@dont-email.me> <87sfzzgr72.fsf@nosuchdomain.example.com>
<GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me>
<nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me>
<1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me>
<87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me>
<87v94tg8sw.fsf@nosuchdomain.example.com> <sdtugu$an9$1@dont-email.me>
<87mtq5f92k.fsf@nosuchdomain.example.com> <sduhq4$3ll$1@dont-email.me>
<87im0tf2rn.fsf@nosuchdomain.example.com> <sduqoh$np9$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="f7dbd806dd1436700e4487cff600874e";
logging-data="18257"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18OfmwWqzda8jePouyFtOhP"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:4Ml6vIOODAXCevmmwl6stygkddo=
sha1:AjVRPMX3wY8ieEP4JbfjtCaQ1LQ=
 by: Keith Thompson - Thu, 29 Jul 2021 18:16 UTC

Bart <bc@freeuk.com> writes:
> On 29/07/2021 18:28, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> This program:
>>>
>>> #include <stdio.h>
>>> 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 <stdio.h>
>
> 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. 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).

--
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 */

Re: Why does C allow structs to have a tag?

<sdusob$h8b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17683&group=comp.lang.c#17683

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 29 Jul 2021 19:41:09 +0100
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <sdusob$h8b$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me> <87im0tf2rn.fsf@nosuchdomain.example.com>
<sduqoh$np9$1@dont-email.me> <87a6m5f0j9.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 29 Jul 2021 18:41:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="aa2fadcab57ffd4f2499933de6d02d17";
logging-data="17675"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18NMoIGTe8bsRxDezmTE4kkxg5GWaRWhdU="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:EPDGIXE25t+seg5X8TpDOgebcPE=
In-Reply-To: <87a6m5f0j9.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210729-0, 29/7/2021), Outbound message
 by: Bart - Thu, 29 Jul 2021 18:41 UTC

On 29/07/2021 19:16, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
>> On 29/07/2021 18:28, Keith Thompson wrote:
>>> Bart <bc@freeuk.com> writes:
>>>> This program:
>>>>
>>>> #include <stdio.h>
>>>> 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 <stdio.h>
>>
>> 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'.

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.

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.

> 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?

Re: Why does C allow structs to have a tag?

<875ywsgb2d.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17684&group=comp.lang.c#17684

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (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: <s9iea5$n5c$1@dont-email.me> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com>
<GvdMI.119844$h8.84268@fx47.iad> <sdrqho$qta$1@dont-email.me>
<nCeMI.8803$Dk6.4825@fx20.iad> <sds1rk$pvj$1@dont-email.me>
<1mgMI.17475$6j.16299@fx04.iad> <sdsme0$2r6$1@dont-email.me>
<87zgu6f367.fsf@nosuchdomain.example.com> <sdsvto$jqt$1@dont-email.me>
<87v94tg8sw.fsf@nosuchdomain.example.com> <sdtugu$an9$1@dont-email.me>
<87mtq5f92k.fsf@nosuchdomain.example.com> <sduhq4$3ll$1@dont-email.me>
<87im0tf2rn.fsf@nosuchdomain.example.com> <sduqoh$np9$1@dont-email.me>
<87a6m5f0j9.fsf@nosuchdomain.example.com> <sdusob$h8b$1@dont-email.me>
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=
 by: Keith Thompson - Thu, 29 Jul 2021 19:43 UTC

Bart <bc@freeuk.com> writes:
> On 29/07/2021 19:16, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> On 29/07/2021 18:28, Keith Thompson wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>>> This program:
>>>>>
>>>>> #include <stdio.h>
>>>>> 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 <stdio.h>
>>>
>>> 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 */

Re: Why does C allow structs to have a tag?

<se10pa$h58$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17688&group=comp.lang.c#17688

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jfbode1...@gmail.com (John Bode)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 09:02:17 -0500
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <se10pa$h58$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me>
<867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me>
<86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
<20210727083246.384@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 30 Jul 2021 14:02:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e50a5e35c2baef83cc3d23b08d01adc9";
logging-data="17576"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3H/+TVxyjB3AgH+4kxDgI"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.12.0
Cancel-Lock: sha1:h5t6/IkOjmSJgL8icMq2wafLSp4=
In-Reply-To: <20210727083246.384@kylheku.com>
Content-Language: en-US
 by: John Bode - Fri, 30 Jul 2021 14:02 UTC

On 7/27/21 10:47 AM, Kaz Kylheku wrote:
> On 2021-07-26, John Bode <jfbode1029@gmail.com> wrote:
>> If you're going to hide a struct or union type behind a typedef name,
>> don't make me hunt down the typedef to know how to access the members -
>> provide an API to do that for me.
>
> I don't find that reasonable; it's pretty common to make typedef names
> for structures just to have a shorthand for declaring them, without
> intending to create a fully opaque type with abstracted operations.
>

Being common doesn't make it right.

> typedef struct version {
> int major;
> int minor;
> } version_t;
>
> The typedef is co-located with the struct declaration; your ediutor
> should be able to jump to the definition of version_t which is
> the above line.
>

I work on remote Linux instances through terminal sessions - my
choices of editor are either vi or emacs, neither of which have
that kind of intelligence.

And I've been dealing with code where typedefs *aren't* co-located
with the type definition.

> Your remark makes sense for a typedef name for a pointer to such
> a structure. That's often intended to be an abstract handle.
>

Yeah, and what I'm saying is don't half-ass the abstraction - either
make it fully abstract or don't bother. Don't hide the information
I need to properly use the type behind a typedef. I would rather you
leave the type "naked", even if it's more eye-stabby or a pain in
the ass to type.

Re: Why does C allow structs to have a tag?

<87pmuzzxx2.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17689&group=comp.lang.c#17689

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 15:19:53 +0100
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <87pmuzzxx2.fsf@bsb.me.uk>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me>
<867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me>
<86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
<20210727083246.384@kylheku.com> <se10pa$h58$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="80de8b44516fce6931b9b570b5cf65ea";
logging-data="13148"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189rCe0x84cy9YSluN141nQQcjfbEnTMro="
Cancel-Lock: sha1:6yJ9lhHK+ViO/Gjk0GP7StD0UHg=
sha1:r17mnUFXCdoWUrG06kvzTKmiC30=
X-BSB-Auth: 1.bca5901330a26109fcf6.20210730151953BST.87pmuzzxx2.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 30 Jul 2021 14:19 UTC

John Bode <jfbode1029@gmail.com> writes:

> On 7/27/21 10:47 AM, Kaz Kylheku wrote:
>> On 2021-07-26, John Bode <jfbode1029@gmail.com> wrote:
>>> If you're going to hide a struct or union type behind a typedef name,
>>> don't make me hunt down the typedef to know how to access the members -
>>> provide an API to do that for me.
>>
>> I don't find that reasonable; it's pretty common to make typedef names
>> for structures just to have a shorthand for declaring them, without
>> intending to create a fully opaque type with abstracted operations.
>
> Being common doesn't make it right.
>
>> typedef struct version {
>> int major;
>> int minor;
>> } version_t;
>> The typedef is co-located with the struct declaration; your ediutor
>> should be able to jump to the definition of version_t which is
>> the above line.
>
> I work on remote Linux instances through terminal sessions - my
> choices of editor are either vi or emacs, neither of which have
> that kind of intelligence.

I use etags+emacs. Works fine. There might even be a more modern and
automatic way to do this, but I tend to stick with what I've used
before.

--
Ben.

Re: Why does C allow structs to have a tag?

<20210730074338.301@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17690&group=comp.lang.c#17690

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 14:51:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20210730074338.301@kylheku.com>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me>
Injection-Date: Fri, 30 Jul 2021 14:51:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9846b85ddcd953d9affebaa8ecfc9c45";
logging-data="1700"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/bvfcbYQf4k7VSM/FTpiG7dmOa0fnIyE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:075EFZvZhM0r3LAai5vwy6y/tWk=
 by: Kaz Kylheku - Fri, 30 Jul 2021 14:51 UTC

On 2021-07-29, Bart <bc@freeuk.com> wrote:
> I'll tell you anyway: [%zu] doesn't work on Windows.

That has no meaning. "Windows" is not a C implementation.

%zu works on Windows if you find a C implementation for Windows with
a run-time library whose printf supports it.

I see that Microsoft is documenting "z". Find the MSDN documentation
page called "Format specification syntax: printf and wprintf functions"
and search within it for "Size Prefixes for printf and wprintf
Format-Type Specifiers".

https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=msvc-160

Also supported in Cygwin and probably other run-times like MinGW-W64.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why does C allow structs to have a tag?

<20210730075144.772@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17691&group=comp.lang.c#17691

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 14:54:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <20210730075144.772@kylheku.com>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
Injection-Date: Fri, 30 Jul 2021 14:54:38 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9846b85ddcd953d9affebaa8ecfc9c45";
logging-data="1700"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yMJRg46f0N6vyXrJO2S11ota4rlUmVh0="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:Dk6nv47in5mWRFkuBj5g42htqpY=
 by: Kaz Kylheku - Fri, 30 Jul 2021 14:54 UTC

On 2021-07-29, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Bart <bc@freeuk.com> writes:
>> On 29/07/2021 03:20, Keith Thompson wrote:
>>> Bart <bc@freeuk.com> writes:
> [...]
>>>> Sure, I can do that (after fixing the code with the right includes and
>>>> avoiding %zu). But that's the trial and error approach.
>>> %zu is the correct format specifier. I'm not even going to ask why
>>> you'd want to avoid it.
>>
>> I'll tell you anyway: it doesn't work on Windows.
>
> Yes, it does. I don't know why it wouldn't work for you. Are you using
> some obsolete version of Windows or of its C implementation?

There is no "its C implementation" in regard to Windows. C programs for
Windows carry their own C run-times.

(Some misguided developers think that an undocumented component called
MSVCRT.DLL in the system folder provides parts of the Library clause of
a C implementation for use by Windows applications; they are simply wrong.)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why does C allow structs to have a tag?

<20210730075445.167@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17692&group=comp.lang.c#17692

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 14:55:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <20210730075445.167@kylheku.com>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me>
Injection-Date: Fri, 30 Jul 2021 14:55:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9846b85ddcd953d9affebaa8ecfc9c45";
logging-data="1700"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/u0pzsUFBgMtdn9PUycbHy7+h5LGybRA8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:shFGaKa+OaA5gNeTaz3ldPNIP/s=
 by: Kaz Kylheku - Fri, 30 Jul 2021 14:55 UTC

On 2021-07-29, Bart <bc@freeuk.com> wrote:
> It's Windows 7. gcc is version 9.2.0.

> This program:
>
> #include <stdio.h>
> int main(void) {printf("%zu\n",sizeof(void*));}
>
> displays 'zu' with gcc, tcc and bcc (my product that uses msvcrt.dll).

The above has no meaning. "gcc" is not the name of any software that
provides a printf function.

Re: Why does C allow structs to have a tag?

<20210730075628.870@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17693&group=comp.lang.c#17693

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 15:06:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <20210730075628.870@kylheku.com>
References: <s9iea5$n5c$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me> <87im0tf2rn.fsf@nosuchdomain.example.com>
<sduqoh$np9$1@dont-email.me> <87a6m5f0j9.fsf@nosuchdomain.example.com>
<sdusob$h8b$1@dont-email.me>
Injection-Date: Fri, 30 Jul 2021 15:06:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9846b85ddcd953d9affebaa8ecfc9c45";
logging-data="1700"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18V70+G+2FvXFvgA3xkPkURkvgQhocYROU="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:eRu6WIetMoAUL+gVq2pkE5+FLNA=
 by: Kaz Kylheku - Fri, 30 Jul 2021 15:06 UTC

On 2021-07-29, Bart <bc@freeuk.com> wrote:
> Anyway, how can the C library be obsolete if it comes /with/ Windows 10?

Windows 10 does not come with a C library.

Windows 10 comes with an undocumented internal component called
MSVCRT.DLL (or something similar) which is in the system folder.

This is used by some utilities that come with Windows.

If you create executable programs which link or load this and call into
it, you're misusing Windows in an undocumented way, like sticking a fork
in a toaster whose user manual describes only bread being stuck into
the toaster.

A few misguided free software developers came up with the idea that that
doing this is a good way to port GNU programs to Windows, because the
GPL has a "system library exception".

So that is to say, a GPL-ed program being linked to Microsoft's
redistributable Visual C run-time would be a GPL violation because that
run-time is not a system library, but just another proprietary
third-party library with a GPL-incompatible license.

Some have additionally defended this idiotic choice because it produces
single .EXE programs that are small. That's like saying, "look at the
weight and space we can save if we don't put heat sinks on these
power transistors; who cares if we are outside of the documented
safe operating area!"

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Why does C allow structs to have a tag?

<se14v7$gb6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17694&group=comp.lang.c#17694

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 16:13:36 +0100
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <se14v7$gb6$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <867dijb22a.fsf@linuxsc.com>
<sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com>
<sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me> <20210730075445.167@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 30 Jul 2021 15:13:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3c3f705f54016a52d58864c170a73423";
logging-data="16742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CJ6kKW3o6dgHcXdmMQUubcBvTUNhpOaw="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:kukMbfj0S2b4ao8bkUJ5IWmQW2c=
In-Reply-To: <20210730075445.167@kylheku.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210730-2, 30/7/2021), Outbound message
 by: Bart - Fri, 30 Jul 2021 15:13 UTC

On 30/07/2021 15:55, Kaz Kylheku wrote:
> On 2021-07-29, Bart <bc@freeuk.com> wrote:
>> It's Windows 7. gcc is version 9.2.0.
>
>> This program:
>>
>> #include <stdio.h>
>> int main(void) {printf("%zu\n",sizeof(void*));}
>>
>> displays 'zu' with gcc, tcc and bcc (my product that uses msvcrt.dll).
>
> The above has no meaning. "gcc" is not the name of any software that
> provides a printf function.
>

OK. But gcc and tcc are products that you expect to make the necessary
arrangements for ensuring they your program can call a C standard
function called "printf".

Which they do, because it generally works. But whatever it is they end
up linking into your program, doesn't support "zu".

I use msvcrt.dll for my compiler's library (sometimes, ucrtbase.dll).
Which library do gcc and tcc use?

I don't know. However, if I peek inside an executable for hello.c
created with tcc, it apparently imports msvcrt.dll, same as mine does.

gcc does the same. But if I try Clang, there is no import library (or no
relevant one). So whatever it uses might be statically linked in.

Same with MSVC (CL), but that is unsurprising, since Clang, despite
being a massive 1600MB installation with LLVM, apparently relies on MS
tools to do the linking, so may use the same library.

But this is all getting away from the point you're trying to make, which
is that gcc has no hand at all it in providing a 'printf' function for
my C programs.

You're wrong.

Further, if I try and compile this program:

extern int printf(long long,...);

int main(void) {
printf((long long)"Hello, World!\n");
}

gcc complains that my printf conflicts with the built-in printf; so it
knows perfectly well what it is. It will even tell me if I get the
format codes wrong!

Re: Why does C allow structs to have a tag?

<se159u$hsm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17695&group=comp.lang.c#17695

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jfbode1...@gmail.com (John Bode)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 10:19:26 -0500
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <se159u$hsm$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me>
<867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me>
<86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
<20210727083246.384@kylheku.com> <se10pa$h58$1@dont-email.me>
<87pmuzzxx2.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 30 Jul 2021 15:19:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="121440413f42af54e59355c851f666da";
logging-data="18326"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CIYKcJUQEAsqUZspBNCqz"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.12.0
Cancel-Lock: sha1:iEfDydT2YHmV+bmmXPCSdWPiqf8=
In-Reply-To: <87pmuzzxx2.fsf@bsb.me.uk>
Content-Language: en-US
 by: John Bode - Fri, 30 Jul 2021 15:19 UTC

On 7/30/21 9:19 AM, Ben Bacarisse wrote:
> John Bode <jfbode1029@gmail.com> writes:
>
>> On 7/27/21 10:47 AM, Kaz Kylheku wrote:
>>> On 2021-07-26, John Bode <jfbode1029@gmail.com> wrote:
>>>> If you're going to hide a struct or union type behind a typedef name,
>>>> don't make me hunt down the typedef to know how to access the members -
>>>> provide an API to do that for me.
>>>
>>> I don't find that reasonable; it's pretty common to make typedef names
>>> for structures just to have a shorthand for declaring them, without
>>> intending to create a fully opaque type with abstracted operations.
>>
>> Being common doesn't make it right.
>>
>>> typedef struct version {
>>> int major;
>>> int minor;
>>> } version_t;
>>> The typedef is co-located with the struct declaration; your ediutor
>>> should be able to jump to the definition of version_t which is
>>> the above line.
>>
>> I work on remote Linux instances through terminal sessions - my
>> choices of editor are either vi or emacs, neither of which have
>> that kind of intelligence.
>
> I use etags+emacs. Works fine. There might even be a more modern and
> automatic way to do this, but I tend to stick with what I've used
> before.
>

Ah. I'm a vi dinosaur. I've tried to learn emacs, but I just don't
have the ability to keep all the key combinations straight. If there's
a way to do it in vi - well, I probably won't use it enough for it
to stick in working memory and will eventually forget about it
completely. I've used or created so many nifty macros over the years
that got used once or twice, then were abandoned.

Irrespective of all of that, my point remains - either fully abstract,
or don't bother.

Re: Why does C allow structs to have a tag?

<se15br$1pog$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17696&group=comp.lang.c#17696

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 17:20:26 +0200
Organization: Aioe.org NNTP Server
Message-ID: <se15br$1pog$1@gioia.aioe.org>
References: <s9iea5$n5c$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me> <87im0tf2rn.fsf@nosuchdomain.example.com>
<sduqoh$np9$1@dont-email.me> <87a6m5f0j9.fsf@nosuchdomain.example.com>
<sdusob$h8b$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="59152"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
X-Notice: Filtered by postfilter v. 0.9.2
X-Mozilla-News-Host: news://news2.informatik.uni-stuttgart.de
Content-Language: en-US
 by: Manfred - Fri, 30 Jul 2021 15:20 UTC

On 7/29/2021 8:41 PM, Bart wrote:
> On 29/07/2021 19:16, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> On 29/07/2021 18:28, Keith Thompson wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>>> This program:
>>>>>
>>>>>     #include <stdio.h>
>>>>>     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 <stdio.h>
>>>
>>>      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'.
>
> 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.

This is a Windows problem, not gcc. As far as I can tell printf comes
with the famous msvcrt.dll, which comes with Windows, BUT also comes
with msvcrXXX.dll as an official redistributable of Visual Studio, that
Microsoft allows to distribute with applications developed with that.
Microsoft gives guidelines for installers about how to deploy these
components, but the result, obviously, is that different Windows boxes
have different C runtimes depending on which packages have been installed.

As a curiosity, you may try this:

#include <Windows.h>
#include <stdio.h>

typedef int (*__cdecl PrintfT)(const char * _Format, ...);

int main(void)
{ if (HMODULE msvcrtLib = LoadLibrary("msvcrt.dll"))
{
PrintfT msvcrtPrintf = (PrintfT)GetProcAddress(msvcrtLib, "printf");

msvcrtPrintf("msvcrtPrintf %zu\n", sizeof(void*));

FreeLibrary(msvcrtLib);
}

printf("printf %zu\n", sizeof(void*));
}

As usual, Microsoft C implementation has always been "peculiar".
Moreover, if you use gcc under Windows (I don't) you are actually using
cygwin's port of gcc *and* some libc implementation, which is /not/
supported by the gcc team.

>
> 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.

Yes, if you use gcc under Windows you are actually importing a chain of
dependencies that you don't want to bother with - That's the reason I
only use gcc on Linux.

>
>> 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?
>
>

Re: Why does C allow structs to have a tag?

<44bl6jzuqu.fsf@be-well.ilk.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17697&group=comp.lang.c#17697

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lguse...@be-well.ilk.org (Lowell Gilbert)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 11:28:25 -0400
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <44bl6jzuqu.fsf@be-well.ilk.org>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me>
<867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me>
<86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
<20210727083246.384@kylheku.com> <se10pa$h58$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="71da62a7f62da6c4e2f697edb096d45a";
logging-data="21567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18H07tcio4l2PrA0IfIgFQL"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (berkeley-unix)
Cancel-Lock: sha1:UVOFHv7+/ox0IB9uAQ2McDhAmfM=
sha1:vAaX4CQmhnYox+mtMvU8lL/t0Gg=
 by: Lowell Gilbert - Fri, 30 Jul 2021 15:28 UTC

John Bode <jfbode1029@gmail.com> writes:

> On 7/27/21 10:47 AM, Kaz Kylheku wrote:
>> typedef struct version {
>> int major;
>> int minor;
>> } version_t;
>> The typedef is co-located with the struct declaration; your ediutor
>> should be able to jump to the definition of version_t which is
>> the above line.
>>
>
> I work on remote Linux instances through terminal sessions - my
> choices of editor are either vi or emacs, neither of which have
> that kind of intelligence.

Digressing, I know, but that's flatly untrue. Both programs have
had basic functionality for that, using external databases, for
thirty or forty years.

--
Lowell Gilbert, embedded/networking software engineer
http://be-well.ilk.org/~lowell/

Re: Why does C allow structs to have a tag?

<se160r$o5c$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17698&group=comp.lang.c#17698

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 16:31:32 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <se160r$o5c$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <20210727083246.384@kylheku.com>
<87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org>
<Tw%LI.6384$XI4.2315@fx09.iad> <sdq5e2$e4v$1@dont-email.me>
<87sfzzgr72.fsf@nosuchdomain.example.com> <GvdMI.119844$h8.84268@fx47.iad>
<sdrqho$qta$1@dont-email.me> <nCeMI.8803$Dk6.4825@fx20.iad>
<sds1rk$pvj$1@dont-email.me> <1mgMI.17475$6j.16299@fx04.iad>
<sdsme0$2r6$1@dont-email.me> <87zgu6f367.fsf@nosuchdomain.example.com>
<sdsvto$jqt$1@dont-email.me> <87v94tg8sw.fsf@nosuchdomain.example.com>
<sdtugu$an9$1@dont-email.me> <87mtq5f92k.fsf@nosuchdomain.example.com>
<sduhq4$3ll$1@dont-email.me> <87im0tf2rn.fsf@nosuchdomain.example.com>
<sduqoh$np9$1@dont-email.me> <87a6m5f0j9.fsf@nosuchdomain.example.com>
<sdusob$h8b$1@dont-email.me> <20210730075628.870@kylheku.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 30 Jul 2021 15:31:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3c3f705f54016a52d58864c170a73423";
logging-data="24748"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hEirRICRkysAjPCaTmqLDYhsLCJ0pvzM="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:R/sUEbZ7zcaDyrVGoZqpXs+BhWo=
In-Reply-To: <20210730075628.870@kylheku.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210730-2, 30/7/2021), Outbound message
 by: Bart - Fri, 30 Jul 2021 15:31 UTC

On 30/07/2021 16:06, Kaz Kylheku wrote:
> On 2021-07-29, Bart <bc@freeuk.com> wrote:
>> Anyway, how can the C library be obsolete if it comes /with/ Windows 10?
>
> Windows 10 does not come with a C library.
>
> Windows 10 comes with an undocumented internal component called
> MSVCRT.DLL (or something similar) which is in the system folder.
>
> This is used by some utilities that come with Windows.
>
> If you create executable programs which link or load this and call into
> it, you're misusing Windows in an undocumented way, like sticking a fork
> in a toaster whose user manual describes only bread being stuck into
> the toaster.

Yet gcc on Windows (or my TDM version of it) does the same. As does Tiny
C. So would any application built with those compilers.

Including tcc.exe itself.

And gcc.exe itself.

(I don't have time to look at various other applications.)

So my attitude is, so what?

Re: Why does C allow structs to have a tag?

<87eebfzufx.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17699&group=comp.lang.c#17699

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 30 Jul 2021 16:34:58 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <87eebfzufx.fsf@bsb.me.uk>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me>
<867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me>
<86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
<20210727083246.384@kylheku.com> <se10pa$h58$1@dont-email.me>
<87pmuzzxx2.fsf@bsb.me.uk> <se159u$hsm$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="80de8b44516fce6931b9b570b5cf65ea";
logging-data="18889"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/m3l+dCOEQxU6lioqsAZyXwLuPesTrbsY="
Cancel-Lock: sha1:I57YMbgIGljDPPE+nTj9tqtpAxA=
sha1:PIORIf7/cQsNBSK4gVa6ycBVE5c=
X-BSB-Auth: 1.50aa53cef345abb4b725.20210730163458BST.87eebfzufx.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 30 Jul 2021 15:34 UTC

John Bode <jfbode1029@gmail.com> writes:

> On 7/30/21 9:19 AM, Ben Bacarisse wrote:
>> John Bode <jfbode1029@gmail.com> writes:
>>
>>> On 7/27/21 10:47 AM, Kaz Kylheku wrote:
>>>> On 2021-07-26, John Bode <jfbode1029@gmail.com> wrote:
>>>>> If you're going to hide a struct or union type behind a typedef name,
>>>>> don't make me hunt down the typedef to know how to access the members -
>>>>> provide an API to do that for me.
>>>>
>>>> I don't find that reasonable; it's pretty common to make typedef names
>>>> for structures just to have a shorthand for declaring them, without
>>>> intending to create a fully opaque type with abstracted operations.
>>>
>>> Being common doesn't make it right.
>>>
>>>> typedef struct version {
>>>> int major;
>>>> int minor;
>>>> } version_t;
>>>> The typedef is co-located with the struct declaration; your ediutor
>>>> should be able to jump to the definition of version_t which is
>>>> the above line.
>>>
>>> I work on remote Linux instances through terminal sessions - my
>>> choices of editor are either vi or emacs, neither of which have
>>> that kind of intelligence.
>> I use etags+emacs. Works fine. There might even be a more modern and
>> automatic way to do this, but I tend to stick with what I've used
>> before.
>
> Ah. I'm a vi dinosaur.

Oh, I thought vi could do this "out of the box". But I'm not a vi
person so I may have got the wrong end of the stick.

> ... If there's
> a way to do it in vi - well, I probably won't use it enough for it
> to stick in working memory and will eventually forget about it
> completely.

That's fine. It the "neither of which [vi or emacs] have that kind of
intelligence" I was commenting on.

--
Ben.

Pages:12345678910111213141516
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor