Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The value of a program is proportional to the weight of its output.


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?

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

  copy mid

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

  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: Mon, 09 Aug 2021 18:27:38 -0700
Organization: None to speak of
Lines: 36
Message-ID: <87mtpqf5rp.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<sesilm$e27$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="21340"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18j5Cbg2wKSIus+RnT1lRB7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:pO1f/KB0rcuh6A5TqlZCxNI1Lxk=
sha1:xPAiPHh4fsyu1OB0AUXmmYZQrrw=
 by: Keith Thompson - Tue, 10 Aug 2021 01:27 UTC

Andrey Tarasevich <andreytarasevich@hotmail.com> writes:
> On 8/9/2021 4:45 PM, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>> [...]
>>> And when I have to play with C, I prefer my own small C compiler; you
>>> know, that one with the faster printf than gcc/tdm.
>> Really? Your *compiler* implements printf? Not the runtime
>> library?
>> Yes, the distinction matters.
>
> While `printf` is certainly a library feature from the formal point of
> view, it is not unusual to see it implemented as an intrinsic at
> compiler level in modern implementations. GCC will happily replace
>
> printf("Hello World\n");
>
> with
>
> puts("Hello World");
>
> at compile-time.

Yes, a compiler can take advantage of standard guarantees about how
standard library functions behave. But it's practical to do so only in
some very narrow special cases. There still has to be a complete
implementation of printf, including interpreting the format string, and
that's provided by the runtime library.

In principle a compiler can do anything that implements the required
behavior, but as far as I know no compilers do that for printf other
than in a few narrow cases.

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

<b19a37dc-6933-4c0b-ad68-c49bd4d72b5bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1014:: with SMTP id d20mr24019630qte.360.1628585713644;
Tue, 10 Aug 2021 01:55:13 -0700 (PDT)
X-Received: by 2002:ad4:4f0f:: with SMTP id fb15mr5501869qvb.22.1628585713482;
Tue, 10 Aug 2021 01:55:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.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: Tue, 10 Aug 2021 01:55:13 -0700 (PDT)
In-Reply-To: <sesbbk$63q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me>
<se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com> <Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com> <sesbbk$63q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b19a37dc-6933-4c0b-ad68-c49bd4d72b5bn@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Tue, 10 Aug 2021 08:55:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 6490
 by: Michael S - Tue, 10 Aug 2021 08:55 UTC

On Tuesday, August 10, 2021 at 1:48:31 AM UTC+3, Bart wrote:
> On 09/08/2021 09:29, Michael S wrote:
> > On Monday, August 9, 2021 at 3:03:15 AM UTC+3, DFS wrote:
> >> On 8/8/2021 6:30 PM, Michael S wrote:
> >>
> >>> Bart and DFS are unique people with unique capabilities. DFS more so,
> >> What are you babbling about?
> >
> > Your shared love to strange tools that wouldn't in top#5 list of choice of professional and likely not in top#10.
> You just don't get it.
>
> When I drive to the shops I like to use my hatchback, I don't need a
> 40-ton truck, or a 747, which are how big and cumbersome those
> professional tools appear to me. (And if younger I'd jump on my bike.)
>
> Who cares about the top 10 anyway? Where was the top 10 when I needed a
> tiny, fast HLL language for my 8-bit micros which actually ran ON those
> same micros? I've used my own languages ever since.
>
> And when I have to play with C, I prefer my own small C compiler; you
> know, that one with the faster printf than gcc/tdm.
> > That loooks like mingw-64. The same compiler/libraries that I tried first and that finished the task in 20 msec - 1000 times faster than you (or Bart) reported.
> A figure which I think you helped to debunk. But the issue at hand is
> what to about the gcc version that runs under the exact same environment
> as tcc.
> > AFAIK, it's C RTL is based on Microsoft's DLL that was originally distributed with VS2013.
> > Recently, they (MSYS2 maintainers) added a variant of library that is called ucrt-something,
> > probably based on more up to date Microsoft's DLL. I didn't try it yet.
> >
> > I didn't see the slowness because I was running it from msys2 command window, i.e. the same environment in which that it was tested by maintainers.
> > When I take generated exe file and try to run it in regular windows command window (cmd.exe)
> > or in powershell window then I see extreme slowness - order of 4.5 sec in cmd.exe and 6.5 sec in powereshell.
> > When I changed the size of cmd window to "traditional" defaults of 80x25, it slowed down to 6 seconds.
> OK, that's more helpful. Now run tcc in the same way, or just use any
> means to write the equivalent text to a file, and use TYPE to display
> it. If that's much faster than doing it from the gcc-compiled program,
> then you've reproduced the problem.
>
> We don't need it 1000 times faster, just as fast as TYPE.
> >
> >>
> >> $gcc -Wall source.c -o prog.exe
> >>
> >> created a huge executable that ran printf() very slowly.
> >>
> >
> > Huge executive is due to presence of symbols. gcc -s (symbols stripped) is just big, not huge.
> >
> > Slowness is due to interaction between startup code in mingw64 library and windows command prompt environment,
> > probably not provisioned by maintainers since they expect their console programs to be run under msys2.
> >
> > As said by several people here, under such combo stdout behaves as unbuffered. So, 160,000 system calls.
> > By themselves, 160,000 system calls are not particularly slow, but Windows console subsystem seems obliged
> > to redraw the whole window each time the character does not fit in window width.
> Huh? The timings I get strongly suggest that something that should be
> done per-string, is getting done per-character. Nothing to do with
> window width, which is anyway a long way the other side of the C runtime
> library they both end up calling.
> >> gcc Windows: slow 3.15s
> >> tcc Windows: quick 0.24s
> >> gcc Linux : incredibly quick (like 0.01, no time to blink)
> >>
> >
> > 0.01 I'd call o.k. rather than "incredibly quick"
> So what is the upper limit of characters per second that can be
> genuinely displayed in a Linux terminal window?
>
> Assuming a character is a bitmapped 12x16 font, on a 24-bit display,
> then writing one character cell (forget antialiasing and such) involves
> writing 600 bytes to video memory. The 23Mcps figure of Ben's (I think
> 7ms to do 160K characters), would involve writing 13GB/s to video
> memory. And that's without handling scrolling.

Assuming infinitely fast CPU, the upper limit is a speed of writing characters (not bitmaps!) to main system RAM by app (C RTL) and then reading them back by renderer. So, on high-end desktop with dual-channel DDR4-3200, ~25,000 Mcps.
Ben's results are lower by 3 orders of magnitude. There is plenty of room for improvements ;-)
Of those billions, only 80x25*60 = 120 Kcps should be processed to bitmaps and transferred to graphics hardware.

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

<c9f2d4b8-119c-4053-b80a-b71fbcfe5298n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:1933:: with SMTP id es19mr10331839qvb.42.1628586293064; Tue, 10 Aug 2021 02:04:53 -0700 (PDT)
X-Received: by 2002:ae9:f504:: with SMTP id o4mr27896262qkg.17.1628586292919; Tue, 10 Aug 2021 02:04:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 10 Aug 2021 02:04:52 -0700 (PDT)
In-Reply-To: <sesbbk$63q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me> <se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com> <Wg_PI.6656$NQ1.5159@fx48.iad> <94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com> <sesbbk$63q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c9f2d4b8-119c-4053-b80a-b71fbcfe5298n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Tue, 10 Aug 2021 09:04:53 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 81
 by: Michael S - Tue, 10 Aug 2021 09:04 UTC

On Tuesday, August 10, 2021 at 1:48:31 AM UTC+3, Bart wrote:
> On 09/08/2021 09:29, Michael S wrote:
> > On Monday, August 9, 2021 at 3:03:15 AM UTC+3, DFS wrote:
> >> On 8/8/2021 6:30 PM, Michael S wrote:
> >>
> >>> Bart and DFS are unique people with unique capabilities. DFS more so,
> >> What are you babbling about?
> >
> > Your shared love to strange tools that wouldn't in top#5 list of choice of professional and likely not in top#10.
> You just don't get it.
>
> When I drive to the shops I like to use my hatchback, I don't need a
> 40-ton truck, or a 747, which are how big and cumbersome those
> professional tools appear to me. (And if younger I'd jump on my bike.)

I prefer my own feet.

>
> Who cares about the top 10 anyway? Where was the top 10 when I needed a
> tiny, fast HLL language for my 8-bit micros which actually ran ON those
> same micros? I've used my own languages ever since.

Back in late 70s or early 80s "official" development systems were running on minis that
were costing 5-years salary of decent developer. So, tools hosted on something more affordable
made a lot of sense, esp. for devs that didn't work for big organization. And obviously the "target"
is by definition the most affordable, because you have to have it anyway.
Times change. Today a decent development workstation costs less than 1-week salary of crap programmer.

>
> And when I have to play with C, I prefer my own small C compiler; you
> know, that one with the faster printf than gcc/tdm.
> > That loooks like mingw-64. The same compiler/libraries that I tried first and that finished the task in 20 msec - 1000 times faster than you (or Bart) reported.
> A figure which I think you helped to debunk. But the issue at hand is
> what to about the gcc version that runs under the exact same environment
> as tcc.
> > AFAIK, it's C RTL is based on Microsoft's DLL that was originally distributed with VS2013.
> > Recently, they (MSYS2 maintainers) added a variant of library that is called ucrt-something,
> > probably based on more up to date Microsoft's DLL. I didn't try it yet.
> >
> > I didn't see the slowness because I was running it from msys2 command window, i.e. the same environment in which that it was tested by maintainers.
> > When I take generated exe file and try to run it in regular windows command window (cmd.exe)
> > or in powershell window then I see extreme slowness - order of 4.5 sec in cmd.exe and 6.5 sec in powereshell.
> > When I changed the size of cmd window to "traditional" defaults of 80x25, it slowed down to 6 seconds.
> OK, that's more helpful. Now run tcc in the same way, or just use any
> means to write the equivalent text to a file, and use TYPE to display
> it. If that's much faster than doing it from the gcc-compiled program,
> then you've reproduced the problem.
>
> We don't need it 1000 times faster, just as fast as TYPE.
> >
> >>
> >> $gcc -Wall source.c -o prog.exe
> >>
> >> created a huge executable that ran printf() very slowly.
> >>
> >
> > Huge executive is due to presence of symbols. gcc -s (symbols stripped) is just big, not huge.
> >
> > Slowness is due to interaction between startup code in mingw64 library and windows command prompt environment,
> > probably not provisioned by maintainers since they expect their console programs to be run under msys2.
> >
> > As said by several people here, under such combo stdout behaves as unbuffered. So, 160,000 system calls.
> > By themselves, 160,000 system calls are not particularly slow, but Windows console subsystem seems obliged
> > to redraw the whole window each time the character does not fit in window width.
> Huh? The timings I get strongly suggest that something that should be
> done per-string, is getting done per-character. Nothing to do with
> window width, which is anyway a long way the other side of the C runtime
> library they both end up calling.
> >> gcc Windows: slow 3.15s
> >> tcc Windows: quick 0.24s
> >> gcc Linux : incredibly quick (like 0.01, no time to blink)
> >>
> >
> > 0.01 I'd call o.k. rather than "incredibly quick"
> So what is the upper limit of characters per second that can be
> genuinely displayed in a Linux terminal window?
>
> Assuming a character is a bitmapped 12x16 font, on a 24-bit display,
> then writing one character cell (forget antialiasing and such) involves
> writing 600 bytes to video memory. The 23Mcps figure of Ben's (I think
> 7ms to do 160K characters), would involve writing 13GB/s to video
> memory. And that's without handling scrolling.

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

<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1007:: with SMTP id d7mr24536457qte.158.1628589822231;
Tue, 10 Aug 2021 03:03:42 -0700 (PDT)
X-Received: by 2002:ac8:4d86:: with SMTP id a6mr4167430qtw.23.1628589822046;
Tue, 10 Aug 2021 03:03:42 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 10 Aug 2021 03:03:41 -0700 (PDT)
In-Reply-To: <seshh0$onu$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:acc1:fb91:4385:6bd1;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:acc1:fb91:4385:6bd1
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad> <94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com> <seshh0$onu$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Tue, 10 Aug 2021 10:03:42 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Tue, 10 Aug 2021 10:03 UTC

On Tuesday, 10 August 2021 at 01:33:47 UTC+1, Bart wrote:
> On 10/08/2021 00:45, Keith Thompson wrote:
> > Bart <b...@freeuk.com> writes:
> > [...]
> >> And when I have to play with C, I prefer my own small C compiler; you
> >> know, that one with the faster printf than gcc/tdm.
> >
> > Really? Your *compiler* implements printf? Not the runtime library?
> >
> > Yes, the distinction matters.
> >
> > [...]
> >
> Not to most normal people, where a language and its implementation is
> just expected to provide print facilities.
>
> The same goes for C. And no the distinction doesn't really matter unless
> you come from the Unix world, which apparently 'owns' C and gets to
> decide all this stuff.
>
> The 'faster' printf I'm refering to is the one inside msvcrt.dll, which
> my gcc/tdm and clang/llvm don't appear capable of using without some
> arm-twisting.
>
> (Would it be that remarkable to implement a function like 'printf'?
> That's the sort of thing I used to do all the time. But since it's
> available in msvcrt.dll, there's no point in repeating stuff I've done
> innumerable times.)
>
I've got a modern Apple system. I had to install an old version of Xcode because
the code base used an old version of boost (always the boost). That broke the
commandline version of clang. It couldn't link in the standard runtime library,
because of some weird incompatibility and passing flags didn't help.

Whilst it was tempting to fiddle with the installation, someone else had written
conan scripts to build the code base. I was afraid that I might break this system,
then I wouldn't be able to fix it.

So yes, a simple "Hello world" program no longer worked. It's a genuine problem
with C's way of doing things. The boost problem was eventually fixed and with
everything up to date, the link problem disappeared.

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

<setjnn$d4c$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 11:17:22 +0100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <setjnn$d4c$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me> <87r1f2f7e1.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 10:17:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="13452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Af9kAZ2uD6duCJriSIswi/N6uAvQfo+A="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:/PYwLEyg1B0pZHPPK8VyOCmgQB4=
In-Reply-To: <87r1f2f7e1.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-6, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 10:17 UTC

On 10/08/2021 01:52, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
>> On 10/08/2021 00:45, Keith Thompson wrote:
>>> Bart <bc@freeuk.com> writes:
>>> [...]
>>>> And when I have to play with C, I prefer my own small C compiler; you
>>>> know, that one with the faster printf than gcc/tdm.
>>> Really? Your *compiler* implements printf? Not the runtime
>>> library?
>>> Yes, the distinction matters.
>>> [...]
>>
>> Not to most normal people, where a language and its implementation is
>> just expected to provide print facilities.
>>
>> The same goes for C. And no the distinction doesn't really matter
>> unless you come from the Unix world, which apparently 'owns' C and
>> gets to decide all this stuff.
>>
>> The 'faster' printf I'm refering to is the one inside msvcrt.dll,
>> which my gcc/tdm and clang/llvm don't appear capable of using without
>> some arm-twisting.
>>
>> (Would it be that remarkable to implement a function like 'printf'?
>> That's the sort of thing I used to do all the time. But since it's
>> available in msvcrt.dll, there's no point in repeating stuff I've done
>> innumerable times.)
>
> You continue to pretend not to understand the distinction between a
> compiler and an implementation in a thread that demonstrates just how
> important that distinction is.
>

I think the [sub-]thread demonstrates exactly the opposite!

The fact is that, outside of Unix (and outside of compilers that
originated in Unix or Unix-like systems, or that try and emulate those)
a compiler is a whole package.

And outside of C, that is generally the case too.

Actually, try and do something different, like compiling this program:

extern int printf(intptr_t);

then gcc/tdm will complain that it it does match what it expects for the
BUILT-IN function 'printf'.

I am just NOT INTERESTED in the 'distinction'.

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

<setnbu$hvb$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 12:19:21 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <setnbu$hvb$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me>
<b19a37dc-6933-4c0b-ad68-c49bd4d72b5bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 11:19:26 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="18411"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Nijt1pmz5gA19mrhNVbWejmcUSt5eKw8="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:w4x9meK7sgVjOT/YR7gKKmjVbXA=
In-Reply-To: <b19a37dc-6933-4c0b-ad68-c49bd4d72b5bn@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-6, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 11:19 UTC

On 10/08/2021 09:55, Michael S wrote:
> On Tuesday, August 10, 2021 at 1:48:31 AM UTC+3, Bart wrote:

>> So what is the upper limit of characters per second that can be
>> genuinely displayed in a Linux terminal window?
>>
>> Assuming a character is a bitmapped 12x16 font, on a 24-bit display,
>> then writing one character cell (forget antialiasing and such) involves
>> writing 600 bytes to video memory. The 23Mcps figure of Ben's (I think
>> 7ms to do 160K characters), would involve writing 13GB/s to video
>> memory. And that's without handling scrolling.
>
> Assuming infinitely fast CPU, the upper limit is a speed of writing characters (not bitmaps!) to main system RAM by app (C RTL) and then reading them back by renderer. So, on high-end desktop with dual-channel DDR4-3200, ~25,000 Mcps.
> Ben's results are lower by 3 orders of magnitude. There is plenty of room for improvements ;-)
> Of those billions, only 80x25*60 = 120 Kcps should be processed to bitmaps and transferred to graphics hardware.

I really meant the upper limit on a real machoine. Otherwise why not
assume an infinitely fast renderer too?

I've just tried my 1-1000000 program on Linux (don't ask me which one),
running on an RPi4 (arm64 but using 32-bit code, I think on a par with
my Windows PC).

My 1-1000000 loop was pretty quick, but not instant, at something over 6
seconds (my Windows PC took 88 seconds), with 0 lines of scrollback.

Writing the text from a file, using 'cat', was under half that
(presumably writing one long string instead of 1000000 short ones, but
this made little difference on Windows).

However, that test ought to show approx 1000000 different things on the
screen (ie. terminal window): for each iteration, a new screen, with a
different number on the first row, ought to appear.

But 6.4 seconds times 60Hz refresh rate means only about 400 different
screenfuls are displayed. This also applies to Windows, which will show
5000 different screenfuls over 88 seconds.

At least with gcc/tdm on Windows, you get 40,000 screenshots for your money!

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

<seu5tf$cvt$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 16:27:39 +0100
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <seu5tf$cvt$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 15:27:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="13309"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZHjWdJhjRKE3o3mySBfuj4jNnV8Qqyuc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:lc2L5OQ9EL013Cmv2BWqD2ieA6o=
In-Reply-To: <1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-6, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 15:27 UTC

On 10/08/2021 11:03, Malcolm McLean wrote:
> On Tuesday, 10 August 2021 at 01:33:47 UTC+1, Bart wrote:
>> On 10/08/2021 00:45, Keith Thompson wrote:
>>> Bart <b...@freeuk.com> writes:
>>> [...]
>>>> And when I have to play with C, I prefer my own small C compiler; you
>>>> know, that one with the faster printf than gcc/tdm.
>>>
>>> Really? Your *compiler* implements printf? Not the runtime library?
>>>
>>> Yes, the distinction matters.
>>>
>>> [...]
>>>
>> Not to most normal people, where a language and its implementation is
>> just expected to provide print facilities.
>>
>> The same goes for C. And no the distinction doesn't really matter unless
>> you come from the Unix world, which apparently 'owns' C and gets to
>> decide all this stuff.
>>
>> The 'faster' printf I'm refering to is the one inside msvcrt.dll, which
>> my gcc/tdm and clang/llvm don't appear capable of using without some
>> arm-twisting.
>>
>> (Would it be that remarkable to implement a function like 'printf'?
>> That's the sort of thing I used to do all the time. But since it's
>> available in msvcrt.dll, there's no point in repeating stuff I've done
>> innumerable times.)
>>
> I've got a modern Apple system. I had to install an old version of Xcode because
> the code base used an old version of boost (always the boost). That broke the
> commandline version of clang. It couldn't link in the standard runtime library,
> because of some weird incompatibility and passing flags didn't help.
>
> Whilst it was tempting to fiddle with the installation, someone else had written
> conan scripts to build the code base. I was afraid that I might break this system,
> then I wouldn't be able to fix it.
>
> So yes, a simple "Hello world" program no longer worked. It's a genuine problem
> with C's way of doing things. The boost problem was eventually fixed and with
> everything up to date, the link problem disappeared.
>

Any language should and usually does provide arrangements for doing i/o.
Whether that is done by built-in features, or libraries written in user
code, is that not important, provided it is self-contained.

(Note that C provides library functions called as though they are
ordinary functions, but it was necessary to add variadic arguments to
make them work as needed. A little untidy.)

In my case, and for console/file destinations, my own runtime (not for
C) eventually ends up calling printf or fprintf from the C library, with
one of these formats to print a single string or single character:

"%s" "%.*s" "*.c"

since it handles all the to-string convertions. (Except for floats where
it uses one of e, f or g with sprintf; it's too much fiddly work
otherwise; I've done it enough times.)

That C library is msvcrt.dll which is a component of Windows (or, when I
tinkered with Linux, it was libc.so.6 or some such library).

So there is no intermediate dependency between my implementation, and
the OS, that someone could tinker with.

According to Keith, every C implementation consists of assorted
components like this:

* Possibly, a discrete preprocessor
* Compiler
* Standard headers
* Assembler
* Linker
* Standard library
* Extensions

which everyone who ever installs an implementation is expected to obtain
from different sources and mix and match to create a custom C system.

Which doesn't really happen. Certainly I've never done it. (Apparently
Unix systems are different and most of these components 'belong' to the
OS, not to a language.)

In the case of my C compiler, everything necessary is bundled into one
executable, except for the standard library, which comes with the OS.

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

<f8744545-f3ce-4645-95d7-b47d3ff0b4e4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:1933:: with SMTP id es19mr12153038qvb.42.1628613753471; Tue, 10 Aug 2021 09:42:33 -0700 (PDT)
X-Received: by 2002:a05:622a:1a9f:: with SMTP id s31mr25777362qtc.151.1628613753274; Tue, 10 Aug 2021 09:42:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.swapon.de!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 10 Aug 2021 09:42:33 -0700 (PDT)
In-Reply-To: <sesbbk$63q$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me> <se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com> <Wg_PI.6656$NQ1.5159@fx48.iad> <94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com> <sesbbk$63q$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f8744545-f3ce-4645-95d7-b47d3ff0b4e4n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Tue, 10 Aug 2021 16:42:33 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 78
 by: Michael S - Tue, 10 Aug 2021 16:42 UTC

On Tuesday, August 10, 2021 at 1:48:31 AM UTC+3, Bart wrote:
> On 09/08/2021 09:29, Michael S wrote:
> > On Monday, August 9, 2021 at 3:03:15 AM UTC+3, DFS wrote:
> >> On 8/8/2021 6:30 PM, Michael S wrote:
> >>
> >>> Bart and DFS are unique people with unique capabilities. DFS more so,
> >> What are you babbling about?
> >
> > Your shared love to strange tools that wouldn't in top#5 list of choice of professional and likely not in top#10.
> You just don't get it.
>
> When I drive to the shops I like to use my hatchback, I don't need a
> 40-ton truck, or a 747, which are how big and cumbersome those
> professional tools appear to me. (And if younger I'd jump on my bike.)
>
> Who cares about the top 10 anyway? Where was the top 10 when I needed a
> tiny, fast HLL language for my 8-bit micros which actually ran ON those
> same micros? I've used my own languages ever since.
>
> And when I have to play with C, I prefer my own small C compiler; you
> know, that one with the faster printf than gcc/tdm.
> > That loooks like mingw-64. The same compiler/libraries that I tried first and that finished the task in 20 msec - 1000 times faster than you (or Bart) reported.
> A figure which I think you helped to debunk. But the issue at hand is
> what to about the gcc version that runs under the exact same environment
> as tcc.
> > AFAIK, it's C RTL is based on Microsoft's DLL that was originally distributed with VS2013.
> > Recently, they (MSYS2 maintainers) added a variant of library that is called ucrt-something,
> > probably based on more up to date Microsoft's DLL. I didn't try it yet.
> >
> > I didn't see the slowness because I was running it from msys2 command window, i.e. the same environment in which that it was tested by maintainers.
> > When I take generated exe file and try to run it in regular windows command window (cmd.exe)
> > or in powershell window then I see extreme slowness - order of 4.5 sec in cmd.exe and 6.5 sec in powereshell.
> > When I changed the size of cmd window to "traditional" defaults of 80x25, it slowed down to 6 seconds.
> OK, that's more helpful. Now run tcc in the same way, or just use any
> means to write the equivalent text to a file, and use TYPE to display
> it. If that's much faster than doing it from the gcc-compiled program,
> then you've reproduced the problem.
>
> We don't need it 1000 times faster, just as fast as TYPE.
> >
> >>
> >> $gcc -Wall source.c -o prog.exe
> >>
> >> created a huge executable that ran printf() very slowly.
> >>
> >
> > Huge executive is due to presence of symbols. gcc -s (symbols stripped) is just big, not huge.
> >
> > Slowness is due to interaction between startup code in mingw64 library and windows command prompt environment,
> > probably not provisioned by maintainers since they expect their console programs to be run under msys2.
> >
> > As said by several people here, under such combo stdout behaves as unbuffered. So, 160,000 system calls.
> > By themselves, 160,000 system calls are not particularly slow, but Windows console subsystem seems obliged
> > to redraw the whole window each time the character does not fit in window width.
> Huh? The timings I get strongly suggest that something that should be
> done per-string, is getting done per-character. Nothing to do with
> window width, which is anyway a long way the other side of the C runtime
> library they both end up calling.

I checked again.
Shorter lines that do not cause screen width overflow (Your original test, modified
by changing format string to "%-16s\n") are printed faster than ultra-long lines in original test.
The difference is not big, around 25%, but consistent.

> >> gcc Windows: slow 3.15s
> >> tcc Windows: quick 0.24s
> >> gcc Linux : incredibly quick (like 0.01, no time to blink)
> >>
> >
> > 0.01 I'd call o.k. rather than "incredibly quick"
> So what is the upper limit of characters per second that can be
> genuinely displayed in a Linux terminal window?
>
> Assuming a character is a bitmapped 12x16 font, on a 24-bit display,
> then writing one character cell (forget antialiasing and such) involves
> writing 600 bytes to video memory. The 23Mcps figure of Ben's (I think
> 7ms to do 160K characters), would involve writing 13GB/s to video
> memory. And that's without handling scrolling.

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

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

  copy mid

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

  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: Tue, 10 Aug 2021 11:17:22 -0700
Organization: None to speak of
Lines: 25
Message-ID: <87im0df9l9.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
<seu5tf$cvt$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="29950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193Xc7IwaiRDU86U/JXB9F4"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:kK+YRTN5Oo9As+y2lPJDAGSyuRw=
sha1:VPmjDaDzFx+healDysWAqWqiVL8=
 by: Keith Thompson - Tue, 10 Aug 2021 18:17 UTC

Bart <bc@freeuk.com> writes:
[...]
> According to Keith, every C implementation consists of assorted
> components like this:
>
> * Possibly, a discrete preprocessor
> * Compiler
> * Standard headers
> * Assembler
> * Linker
> * Standard library
> * Extensions
>
> which everyone who ever installs an implementation is expected to
> obtain from different sources and mix and match to create a custom C
> system.

That is a lie. I did not say 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?

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

  copy mid

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

  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: Tue, 10 Aug 2021 11:22:03 -0700
Organization: None to speak of
Lines: 38
Message-ID: <87eeb1f9dg.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me> <87r1f2f7e1.fsf@nosuchdomain.example.com>
<setjnn$d4c$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="29950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18i2a7NPqrWqTzmBHi8MxMA"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:T5db06ulNXjEeM5DgiYcpi0izRg=
sha1:JMTNWJrFxIBuwLLVCGa8JLGIr4Q=
 by: Keith Thompson - Tue, 10 Aug 2021 18:22 UTC

Bart <bc@freeuk.com> writes:
> On 10/08/2021 01:52, Keith Thompson wrote:
[...]
>> You continue to pretend not to understand the distinction between a
>> compiler and an implementation in a thread that demonstrates just how
>> important that distinction is.
>
> I think the [sub-]thread demonstrates exactly the opposite!
>
> The fact is that, outside of Unix (and outside of compilers that
> originated in Unix or Unix-like systems, or that try and emulate
> those) a compiler is a whole package.

You use TDM-GCC. Yes, it's a "whole package" by the time you download
it, but it was assembled from independent components.

> And outside of C, that is generally the case too.
>
> Actually, try and do something different, like compiling this program:
>
> extern int printf(intptr_t);
>
> then gcc/tdm will complain that it it does match what it expects for
> the BUILT-IN function 'printf'.

Yes, because it knows what the standard guarantees for the printf
function, not because it knows anything about a particular library
implementation.

> I am just NOT INTERESTED in the 'distinction'.

You're interested enough to argue about it every time someone mentions
it.

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

<seuil3$3i2$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 20:05:02 +0100
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <seuil3$3i2$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me> <87r1f2f7e1.fsf@nosuchdomain.example.com>
<setjnn$d4c$1@dont-email.me> <87eeb1f9dg.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 19:05:07 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="3650"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1vLcoCfvJgrs/IY+ng3fOZufitNpvhnE="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:abYbMSq+n4DvnWeUh+iLUso+ii8=
In-Reply-To: <87eeb1f9dg.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-14, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 19:05 UTC

On 10/08/2021 19:22, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
>> On 10/08/2021 01:52, Keith Thompson wrote:
> [...]
>>> You continue to pretend not to understand the distinction between a
>>> compiler and an implementation in a thread that demonstrates just how
>>> important that distinction is.
>>
>> I think the [sub-]thread demonstrates exactly the opposite!
>>
>> The fact is that, outside of Unix (and outside of compilers that
>> originated in Unix or Unix-like systems, or that try and emulate
>> those) a compiler is a whole package.
>
> You use TDM-GCC. Yes, it's a "whole package" by the time you download
> it, but it was assembled from independent components.

How many different ones are there (I mean as downloadable, assembled,
complete products for other people to use) for plain Windows, and how do
they differ?

gcc itself probably consists of lots of different components too,
written by 100s of people; where does it end?

>> And outside of C, that is generally the case too.
>>
>> Actually, try and do something different, like compiling this program:
>>
>> extern int printf(intptr_t);
>>
>> then gcc/tdm will complain that it it does match what it expects for
>> the BUILT-IN function 'printf'.
>
> Yes, because it knows what the standard guarantees for the printf
> function, not because it knows anything about a particular library
> implementation.
>
>> I am just NOT INTERESTED in the 'distinction'.
>
> You're interested enough to argue about it every time someone mentions
> it.
>

Every time someone moans about my casually saying 'gcc' when I mean the
entire bundle for plain Windows.

(I've even had to start saying 'plain Windows' now because nobody here
seems capable of using it without doing it through Cygwin or MSYS2 or WSL.)

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

<seujms$n3r$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 20:23:03 +0100
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <seujms$n3r$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
<seu5tf$cvt$1@dont-email.me> <87im0df9l9.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 19:23:08 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="23675"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18JYSlVcALuWsbhzmKarXHgyrvXsSaIHDY="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:Akl5c+OTMgXW64IEz3UgzRRmWb8=
In-Reply-To: <87im0df9l9.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-14, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 19:23 UTC

On 10/08/2021 19:17, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [...]
>> According to Keith, every C implementation consists of assorted
>> components like this:
>>
>> * Possibly, a discrete preprocessor
>> * Compiler
>> * Standard headers
>> * Assembler
>> * Linker
>> * Standard library
>> * Extensions
>>
>> which everyone who ever installs an implementation is expected to
>> obtain from different sources and mix and match to create a custom C
>> system.
>
> That is a lie. I did not say that.

You said something like that 5 minutes later:

KT:
> You use TDM-GCC. Yes, it's a "whole package" by the time you download
> it, but it was assembled from independent components.
>

Here's another post:

On 31/07/2021 20:58, Keith Thompson wrote:
> "cc" is as driver program that might invoke several different programs,
> including a preprocessor, a compiler, an assembler, and a linker. It
> was perfectly reasonable for K&R

And another:

On 31/07/2021 05:14, Keith Thompson wrote:
> You very commonly gloss over the distinction between an*implementation*
> and a*compiler*. An implementation consists of several components; the
> compiler is just one of them.

Even if someone doesn't create their own bundle, you imply that they
need to be aware of exactly what it comprises.

(As though I would have any clue as to what is what: I have two gcc
installations; tdm/gcc is 4900 files/215 directories/560MB; the other is
DFS's mingw64, 4850 files/195 directories/850MB.

Clang is part of an LLVM download which is 370 files/34
directories/1730MB, but I believe it still requires MSVC or MSBUILD
tools (I get those confused) for certain parts. I think that MS product
is 12300 files/1330 directories/2550MB.

My own product is 1 file/1 directory/1MB (0 directories really as you
can stick the exe where you want); this one I do have a clue about!)

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

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

  copy mid

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

  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: Tue, 10 Aug 2021 13:49:46 -0700
Organization: None to speak of
Lines: 64
Message-ID: <87y299uis5.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me> <87r1f2f7e1.fsf@nosuchdomain.example.com>
<setjnn$d4c$1@dont-email.me> <87eeb1f9dg.fsf@nosuchdomain.example.com>
<seuil3$3i2$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="12658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191VLj6C9zpQz5cfoO8lSGU"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:h/rlU09cs4wcrl74A44a7POKbc8=
sha1:hZytpUsOb/bv8Rye4Uz75Q3ybP4=
 by: Keith Thompson - Tue, 10 Aug 2021 20:49 UTC

Bart <bc@freeuk.com> writes:
> On 10/08/2021 19:22, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> On 10/08/2021 01:52, Keith Thompson wrote:
>> [...]
>>>> You continue to pretend not to understand the distinction between a
>>>> compiler and an implementation in a thread that demonstrates just how
>>>> important that distinction is.
>>>
>>> I think the [sub-]thread demonstrates exactly the opposite!
>>>
>>> The fact is that, outside of Unix (and outside of compilers that
>>> originated in Unix or Unix-like systems, or that try and emulate
>>> those) a compiler is a whole package.
>> You use TDM-GCC. Yes, it's a "whole package" by the time you
>> download
>> it, but it was assembled from independent components.
>
> How many different ones are there (I mean as downloadable, assembled,
> complete products for other people to use) for plain Windows, and how
> do they differ?
>
> gcc itself probably consists of lots of different components too,
> written by 100s of people; where does it end?

Explaining this to you is obviously a waste of time.

[...]

>>> And outside of C, that is generally the case too.
>>>
>>> Actually, try and do something different, like compiling this program:
>>>
>>> extern int printf(intptr_t);
>>>
>>> then gcc/tdm will complain that it it does match what it expects for
>>> the BUILT-IN function 'printf'.
>> Yes, because it knows what the standard guarantees for the printf
>> function, not because it knows anything about a particular library
>> implementation.
>>
>>> I am just NOT INTERESTED in the 'distinction'.
>> You're interested enough to argue about it every time someone
>> mentions
>> it.
>
> Every time someone moans about my casually saying 'gcc' when I mean
> the entire bundle for plain Windows.

Yes, because you complain about 'gcc" not implementing printf correctly.
Again, I'm not going to explain again why that's misleading.

> (I've even had to start saying 'plain Windows' now because nobody here
> seems capable of using it without doing it through Cygwin or MSYS2 or
> WSL.)

I usually use Cygwin myself. Of course poeple are going to use examples
they're familiar with. I am obviously capable of using "plain Windows",
since I discussed doing so just recently.

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

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

  copy mid

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

  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: Tue, 10 Aug 2021 14:00:54 -0700
Organization: None to speak of
Lines: 92
Message-ID: <87tujxui9l.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
<seu5tf$cvt$1@dont-email.me> <87im0df9l9.fsf@nosuchdomain.example.com>
<seujms$n3r$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="12658"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wC2NqfeyTdgphtvzv/1+m"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:7P0EaCq3X1GSV1sB1RMjfyJrBWk=
sha1:iyJRan83rMyjFqnZZzFV1gBbWNE=
 by: Keith Thompson - Tue, 10 Aug 2021 21:00 UTC

Bart <bc@freeuk.com> writes:
> On 10/08/2021 19:17, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>> [...]
>>> According to Keith, every C implementation consists of assorted
>>> components like this:
>>>
>>> * Possibly, a discrete preprocessor
>>> * Compiler
>>> * Standard headers
>>> * Assembler
>>> * Linker
>>> * Standard library
>>> * Extensions
>>>
>>> which everyone who ever installs an implementation is expected to
>>> obtain from different sources and mix and match to create a custom C
>>> system.
>> That is a lie. I did not say that.
>
> You said something like that 5 minutes later:
>
> KT:
>> You use TDM-GCC. Yes, it's a "whole package" by the time you download
>> it, but it was assembled from independent components.

I did not say or imply that "everyone who ever installs an
implementation" is required to assemble the components. TDM-GCC is
assembled by the maintainers of TDM-GCC. The end user installs it as a
single package.

> Here's another post:
>
> On 31/07/2021 20:58, Keith Thompson wrote:
>> "cc" is as driver program that might invoke several different programs,
>> including a preprocessor, a compiler, an assembler, and a linker. It
>> was perfectly reasonable for K&R

Yes. I said nothing about the end user mixing and matching those
programs.

> And another:
>
> On 31/07/2021 05:14, Keith Thompson wrote:
>> You very commonly gloss over the distinction between an*implementation*
>> and a*compiler*. An implementation consists of several components; the
>> compiler is just one of them.
>
> Even if someone doesn't create their own bundle, you imply that they
> need to be aware of exactly what it comprises.

You lied when you claimed that I said that the end user must obtain the
components from different sources and mix and match them. I never said
or implied that. The mixing and matching is usually done by package
maintainers. And yes, sometimes the components of a given
implementation are developed together and perhaps not intended to be
used with other components.

It can be very useful to understand that an implementation is made up of
components, and which components make up the implementation you're
using. For example, such an understanding can prevent someone from
complaining that gcc doesn't implement printf correctly.

> (As though I would have any clue as to what is what: I have two gcc
> installations; tdm/gcc is 4900 files/215 directories/560MB; the other
> is DFS's mingw64, 4850 files/195 directories/850MB.
>
> Clang is part of an LLVM download which is 370 files/34
> directories/1730MB, but I believe it still requires MSVC or MSBUILD
> tools (I get those confused) for certain parts. I think that MS
> product is 12300 files/1330 directories/2550MB.
>
> My own product is 1 file/1 directory/1MB (0 directories really as you
> can stick the exe where you want); this one I do have a clue about!)

I accept that you have a clue about all this. I think you understand it
perfectly well. The mystery is why you pretend not to and get angry
when someone points it out.

If your own product combines all the elements of a C implementation into
a siungle executable file, that's fine. It's an unusual approach, but I
suppose there's no particular reason not to do it that way.

I presume from context that this single executable file includes the
code that implements printf rather than generating calls to an external
library. If not, it's not a complete C implementation (which would also
be just fine).

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

<FiCQI.401$uk4.259@fx20.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!feeder5.feed.usenet.farm!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx20.iad.POSTED!not-for-mail
From: nos...@dfs.com (DFS)
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
X-Mozilla-News-Host: news://usnews.blocknews.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <WFWPI.1865$un2.1665@fx04.iad>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 74
Message-ID: <FiCQI.401$uk4.259@fx20.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Tue, 10 Aug 2021 21:35:33 UTC
Organization: blocknews - www.blocknews.net
Date: Tue, 10 Aug 2021 14:35:31 -0700
X-Received-Bytes: 3357
 by: DFS - Tue, 10 Aug 2021 21:35 UTC

On 8/8/2021 12:56 PM, Scott Lurndal wrote:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>> Bart <bc@freeuk.com> writes:
>>
>>>> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
>>>
>>> You're right; this program:
>>>
>>> #include <stdio.h>
>>> int main(void) {
>>> for (int i=0; i<10000; ++i)
>>> printf("%-16s","1234567890"); // no newlines
>>> }
>>>
>>> runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
>>> never noticed before.
>>
>> You often post times with no indication of what's being measured. The
>> compiler probably has little to do with it. What C library is being
>> used? How is the output handled? On my laptop, compiled with gcc
>> 10.3.0 and linked against libc6 version 2.33, it's almost too fast to
>> measure:
>>
>> $ time ./o >/dev/null
>>
>> real 0m0.007s
>> user 0m0.004s
>> sys 0m0.004s
>
> An aggressive optimizer (speed vs space) could optimize it
> into a single puts of a 160,000 character string.

=================================================================

//option 1: one puts per line (suggested by bart)
int i = 0;
char buff[longword+3];
char line[tcols];
*line = '\0';
while(i < matchcnt) {
for(int j = 1;j<=maxcols;j++) {
sprintf(buff,"%-*s ",longword,matchwords[i++]);
strcat(line,buff);
}
puts(line);
*buff = '\0';
*line = '\0';
}

=================================================================

//option 2: one big string, one puts (per Lurndal)
int i = 0;
char buff[longword+3];
char line[(longword + 3) * matchcnt];
*line = '\0';
while(i < matchcnt) {
for(int j = 1;j<=maxcols;j++) {
sprintf(buff,"%-*s ",longword,matchwords[i++]);
strcat(line,buff);
}
*buff = '\0';
strcat(line,"\n");
} puts(line);
=================================================================

726 words across 5 columns
option 1: 0.06s
option 2: 0.05s

A significant speed increase.

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

<poCQI.37363$EF2.25668@fx47.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!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!fx47.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> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad>
Lines: 83
Message-ID: <poCQI.37363$EF2.25668@fx47.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 10 Aug 2021 21:41:41 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 10 Aug 2021 21:41:41 GMT
X-Received-Bytes: 3507
 by: Scott Lurndal - Tue, 10 Aug 2021 21:41 UTC

DFS <nospam@dfs.com> writes:
>On 8/8/2021 12:56 PM, Scott Lurndal wrote:
>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>> Bart <bc@freeuk.com> writes:
>>>
>>>>> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
>>>>
>>>> You're right; this program:
>>>>
>>>> #include <stdio.h>
>>>> int main(void) {
>>>> for (int i=0; i<10000; ++i)
>>>> printf("%-16s","1234567890"); // no newlines
>>>> }
>>>>
>>>> runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
>>>> never noticed before.
>>>
>>> You often post times with no indication of what's being measured. The
>>> compiler probably has little to do with it. What C library is being
>>> used? How is the output handled? On my laptop, compiled with gcc
>>> 10.3.0 and linked against libc6 version 2.33, it's almost too fast to
>>> measure:
>>>
>>> $ time ./o >/dev/null
>>>
>>> real 0m0.007s
>>> user 0m0.004s
>>> sys 0m0.004s
>>
>> An aggressive optimizer (speed vs space) could optimize it
>> into a single puts of a 160,000 character string.
>
>=================================================================
>
>//option 1: one puts per line (suggested by bart)
>int i = 0;
>char buff[longword+3];
>char line[tcols];
>*line = '\0';
>while(i < matchcnt) {
> for(int j = 1;j<=maxcols;j++) {
> sprintf(buff,"%-*s ",longword,matchwords[i++]);
> strcat(line,buff);
> }
> puts(line);
> *buff = '\0';
> *line = '\0';
>}
>
>=================================================================
>
>//option 2: one big string, one puts (per Lurndal)
>int i = 0;
>char buff[longword+3];
>char line[(longword + 3) * matchcnt];
>*line = '\0';
>while(i < matchcnt) {
> for(int j = 1;j<=maxcols;j++) {
> sprintf(buff,"%-*s ",longword,matchwords[i++]);
> strcat(line,buff);
> }
> *buff = '\0';
> strcat(line,"\n");
>}
>puts(line);
>
>=================================================================
>
>
>726 words across 5 columns
>option 1: 0.06s
>option 2: 0.05s
>
>A significant speed increase.

I was suggesting that the compiler could have just
stored a 160k string in RO storage and called puts
with a pointer to it. There is no need to construct
it at runtime.

The entire program would reduce to a single call
to puts with a compiler generated constant string.

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

<seusif$6gt$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 22:54:17 +0100
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <seusif$6gt$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
<seu5tf$cvt$1@dont-email.me> <87im0df9l9.fsf@nosuchdomain.example.com>
<seujms$n3r$1@dont-email.me> <87tujxui9l.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 21:54:23 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="6685"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z+672EJOPoMfIZKYwmIYbUJD7tuJAmug="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:4pXLSbSxTO0tRjMHwX7bpvHjp3M=
In-Reply-To: <87tujxui9l.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-14, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 21:54 UTC

On 10/08/2021 22:00, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:

>> My own product is 1 file/1 directory/1MB (0 directories really as you
>> can stick the exe where you want); this one I do have a clue about!)
>
> I accept that you have a clue about all this. I think you understand it
> perfectly well. The mystery is why you pretend not to and get angry
> when someone points it out.
>
> If your own product combines all the elements of a C implementation into
> a siungle executable file, that's fine. It's an unusual approach, but I
> suppose there's no particular reason not to do it that way.
>
> I presume from context that this single executable file includes the
> code that implements printf rather than generating calls to an external
> library. If not, it's not a complete C implementation (which would also
> be just fine).

When I first encountered the C library, I considered it as part of
Windows, since it was described in the same documentation set, and it
has always been shipped with that OS.

I don't therefore see any reason to spend a year or two reimplementating
the 1400 functions in msvcrt.dll, when msvcrt.dll does the job perfectly
well and will always be available.

Especially when the same library is a dynamic import for most EXE and
DLL files, including gcc.exe itself:

----------------------------------------------------

Executable file gcc.exe
PE Sig:PE
Coff header: (34404,11,0,1283584,0,240,558)
Machine: 8664
.....

Import Directory
.....

Entry: 13c028
Lookup RVA: 13c1f8
Time Date Stamp: 0
Fwd Chain: 0
Name RVA: 13d7bc
Name: msvcrt.dll <<<----------
Import Addr RVA: 13c788
Import:13cf38 38 __C_specific_handler
Import:13cf50 40 ___lc_codepage_func
Import:13cf66 43 ___mb_cur_max_func
Import:13cf7c 52 __getmainargs
.....

Note that my msvcrt.dll is about 600KB. If absolutely necessary it's
possible to bundle it into bcc.exe, and UPX [compress] the resulting
1.7MB file into a compact 0.5MB executable.

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

<VNCQI.5685$Ug5.514@fx24.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx24.iad.POSTED!not-for-mail
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
From: nos...@dfs.com (DFS)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <poCQI.37363$EF2.25668@fx47.iad>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 94
Message-ID: <VNCQI.5685$Ug5.514@fx24.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Tue, 10 Aug 2021 22:08:53 UTC
Organization: blocknews - www.blocknews.net
Date: Tue, 10 Aug 2021 15:08:51 -0700
X-Received-Bytes: 4118
 by: DFS - Tue, 10 Aug 2021 22:08 UTC

On 8/10/2021 2:41 PM, Scott Lurndal wrote:
> DFS <nospam@dfs.com> writes:
>> On 8/8/2021 12:56 PM, Scott Lurndal wrote:
>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>> Bart <bc@freeuk.com> writes:
>>>>
>>>>>> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
>>>>>
>>>>> You're right; this program:
>>>>>
>>>>> #include <stdio.h>
>>>>> int main(void) {
>>>>> for (int i=0; i<10000; ++i)
>>>>> printf("%-16s","1234567890"); // no newlines
>>>>> }
>>>>>
>>>>> runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
>>>>> never noticed before.
>>>>
>>>> You often post times with no indication of what's being measured. The
>>>> compiler probably has little to do with it. What C library is being
>>>> used? How is the output handled? On my laptop, compiled with gcc
>>>> 10.3.0 and linked against libc6 version 2.33, it's almost too fast to
>>>> measure:
>>>>
>>>> $ time ./o >/dev/null
>>>>
>>>> real 0m0.007s
>>>> user 0m0.004s
>>>> sys 0m0.004s
>>>
>>> An aggressive optimizer (speed vs space) could optimize it
>>> into a single puts of a 160,000 character string.
>>
>> =================================================================
>>
>> //option 1: one puts per line (suggested by bart)
>> int i = 0;
>> char buff[longword+3];
>> char line[tcols];
>> *line = '\0';
>> while(i < matchcnt) {
>> for(int j = 1;j<=maxcols;j++) {
>> sprintf(buff,"%-*s ",longword,matchwords[i++]);
>> strcat(line,buff);
>> }
>> puts(line);
>> *buff = '\0';
>> *line = '\0';
>> }
>>
>> =================================================================
>>
>> //option 2: one big string, one puts (per Lurndal)
>> int i = 0;
>> char buff[longword+3];
>> char line[(longword + 3) * matchcnt];
>> *line = '\0';
>> while(i < matchcnt) {
>> for(int j = 1;j<=maxcols;j++) {
>> sprintf(buff,"%-*s ",longword,matchwords[i++]);
>> strcat(line,buff);
>> }
>> *buff = '\0';
>> strcat(line,"\n");
>> }
>> puts(line);
>>
>> =================================================================
>>
>>
>> 726 words across 5 columns
>> option 1: 0.06s
>> option 2: 0.05s
>>
>> A significant speed increase.
>
> I was suggesting that the compiler could have just
> stored a 160k string in RO storage and called puts
> with a pointer to it. There is no need to construct
> it at runtime.
>
> The entire program would reduce to a single call
> to puts with a compiler generated constant string.

Gotcha.

I just noticed something in my program. Using option 2 above, the
version compiled by tcc crashes when the value in line 3 is large
(1027424). The version compiled by gcc doesn't crash.

Is that a stack overflow issue?

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

<seuu75$il3$1@dont-email.me>

  copy mid

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

  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: Tue, 10 Aug 2021 23:22:24 +0100
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <seuu75$il3$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 10 Aug 2021 22:22:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ebac4182797cc3b1d63c47001b000224";
logging-data="19107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18YDmO1dCwsSgQ/GvRKo62TAqF7JGoT3cs="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:IWvTZNSMPbwosBvf5uHbgVllySo=
In-Reply-To: <VNCQI.5685$Ug5.514@fx24.iad>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-14, 10/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 22:22 UTC

On 10/08/2021 23:08, DFS wrote:
> On 8/10/2021 2:41 PM, Scott Lurndal wrote:

>> I was suggesting that the compiler could have just
>> stored a 160k string in RO storage and called puts
>> with a pointer to it.   There is no need to construct
>> it at runtime.
>>
>> The entire program would reduce to a single call
>> to puts with a compiler generated constant string.
>
> Gotcha.
>
> I just noticed something in my program.  Using option 2 above, the
> version compiled by tcc crashes when the value in line 3 is large
> (1027424).  The version compiled by gcc doesn't crash.
>
> Is that a stack overflow issue?
>

Yes, you're using VLAs, (maybe in option 1 too if longword and tcols are
not compile-time constants).

Typical stack size is a few MB. It seems the default stack size of tcc
is smaller than of gcc**. tcc crashes with this:

int n=2000000;
char str[n];
memset(str,0,n);

but gcc doesn't, until you change n to 4000000. If I dump the two
executables, then the gcc one contains this:

Stack reserve: 2097152
Stack commit: 4096

tcc's has:

Stack reserve: 1048576
Stack commit: 4096

There are probably ways of increasing the stack size, but better not to
use VLAs for arrays of this size. (Use static arrays or allocate on the
heap.)

(**For the pedantics here, this is not *the* gcc, but my tdm/gcc
version. However the mingw64 version does the same.)

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

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

  copy mid

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

  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: Tue, 10 Aug 2021 15:32:00 -0700
Organization: None to speak of
Lines: 36
Message-ID: <87pmulue1r.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
<1617a372-38e2-4729-a058-8f1ca95d5a49n@googlegroups.com>
<seu5tf$cvt$1@dont-email.me> <87im0df9l9.fsf@nosuchdomain.example.com>
<seujms$n3r$1@dont-email.me> <87tujxui9l.fsf@nosuchdomain.example.com>
<seusif$6gt$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="7af0248d926c60a6cf88b66f75a520dd";
logging-data="19769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LZHAIhIzgDKhjalFFnXV7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:S+yY/I8ZH3uT+XSmr0h7ECTNIFU=
sha1:cffvSDutf9mJIfs27t+NxTFeb0w=
 by: Keith Thompson - Tue, 10 Aug 2021 22:32 UTC

Bart <bc@freeuk.com> writes:
> On 10/08/2021 22:00, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>>> My own product is 1 file/1 directory/1MB (0 directories really as you
>>> can stick the exe where you want); this one I do have a clue about!)
>> I accept that you have a clue about all this. I think you
>> understand it
>> perfectly well. The mystery is why you pretend not to and get angry
>> when someone points it out.
>> If your own product combines all the elements of a C implementation
>> into
>> a siungle executable file, that's fine. It's an unusual approach, but I
>> suppose there's no particular reason not to do it that way.
>> I presume from context that this single executable file includes the
>> code that implements printf rather than generating calls to an external
>> library. If not, it's not a complete C implementation (which would also
>> be just fine).
>
> When I first encountered the C library, I considered it as part of
> Windows, since it was described in the same documentation set, and it
> has always been shipped with that OS.
>
> I don't therefore see any reason to spend a year or two
> reimplementating the 1400 functions in msvcrt.dll, when msvcrt.dll
> does the job perfectly well and will always be available.

Nobody said you should. Your statements led me to infer, apparently
incorrectly, that you were claiming that your single executable was a
complete 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?

<TEEQI.5686$Ug5.143@fx24.iad>

  copy mid

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

  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!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx24.iad.POSTED!not-for-mail
From: nos...@dfs.com (DFS)
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
X-Mozilla-News-Host: news://usnews.blocknews.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <seuu75$il3$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 114
Message-ID: <TEEQI.5686$Ug5.143@fx24.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Wed, 11 Aug 2021 00:15:47 UTC
Organization: blocknews - www.blocknews.net
Date: Tue, 10 Aug 2021 20:15:46 -0400
X-Received-Bytes: 4936
 by: DFS - Wed, 11 Aug 2021 00:15 UTC

On 8/10/2021 6:22 PM, Bart wrote:
> On 10/08/2021 23:08, DFS wrote:
>> On 8/10/2021 2:41 PM, Scott Lurndal wrote:
>
>>> I was suggesting that the compiler could have just
>>> stored a 160k string in RO storage and called puts
>>> with a pointer to it.   There is no need to construct
>>> it at runtime.
>>>
>>> The entire program would reduce to a single call
>>> to puts with a compiler generated constant string.
>>
>> Gotcha.
>>
>> I just noticed something in my program.  Using option 2 above, the
>> version compiled by tcc crashes when the value in line 3 is large
>> (1027424).  The version compiled by gcc doesn't crash.
>>
>> Is that a stack overflow issue?
>>
>
> Yes, you're using VLAs, (maybe in option 1 too if longword and tcols are
> not compile-time constants).

They're not. Longword is the longest word (1 to 31) in a result set,
and tcols is the width of your terminal at the time you do the search.

Here's the app: https://imgur.com/a/cQdvAeM

> Typical stack size is a few MB. It seems the default stack size of tcc
> is smaller than of gcc**. tcc crashes with this:
>
>     int n=2000000;
>     char str[n];
>     memset(str,0,n);
>
> but gcc doesn't, until you change n to 4000000. If I dump the two
> executables, then the gcc one contains this:
>
>   Stack reserve:    2097152
>   Stack commit:     4096
>
> tcc's has:
>
>   Stack reserve:    1048576
>   Stack commit:     4096
>
> There are probably ways of increasing the stack size, but better not to
> use VLAs for arrays of this size. (Use static arrays or allocate on the
> heap.)

Thanks. I created a static array[10_000_000] outside the function, and
it handled large results sets just fine. But another issue popped up,
using option 2, which concatenates words one by one into that static
array, then does one puts() at the end.

Turns out it's VERY slow for large result sets.

Option 1 Option 2
substring catt: 91 matches found 0.04s 0.038s
substring cat : 3710 matches found 0.20s 0.16s
substring ca : 22793 matches found 1.39s 2.25s
substring c : 128689 matches found 7.75s 57.91s
substring e : 252896 matches found 15.29s 216.58s

Option 1 starts printing immediately, one line at a time. Option 2 sits
there constructing that long string for quite a while. Too long I
think. What might I be doing wrong?

Note: the timing includes time to print to screen. Just finding the
word matches is 0.03s using either option.

=================================================================

//option 1: one puts per line (suggested by bart)
int i = 0;
char buff[longword+3];
char line[tcols];
*line = '\0';
while(i < matchcnt) {
for(int j = 1;j<=maxcols;j++) {
sprintf(buff,"%-*s ",longword,matchwords[i++]);
strcat(line,buff);
}
puts(line);
*buff = '\0';
*line = '\0';
}

=================================================================

//option 2: one big string, one puts (per Lurndal)
static char line[10000000]; //declared outside the func

int i = 0;
char buff[longword+3];
*line = '\0';
while(i < matchcnt) {
for(int j = 1;j<=maxcols;j++) {
sprintf(buff,"%-*s ",longword,matchwords[i++]);
strcat(line,buff);
}
*buff = '\0';
strcat(line,"\n");
} puts(line);

=================================================================

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

<sf021q$78n$1@z-news.wcss.wroc.pl>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Wed, 11 Aug 2021 08:34:02 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 75
Message-ID: <sf021q$78n$1@z-news.wcss.wroc.pl>
References: <s9iea5$n5c$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1628670842 7447 156.17.86.1 (11 Aug 2021 08:34:02 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Wed, 11 Aug 2021 08:34:02 +0000 (UTC)
Cancel-Lock: sha1:8oO4rN+HrXh9AGhh6Se44BA1Gtk=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Wed, 11 Aug 2021 08:34 UTC

DFS <nospam@dfs.com> wrote:
>
> Thanks. I created a static array[10_000_000] outside the function, and
> it handled large results sets just fine. But another issue popped up,
> using option 2, which concatenates words one by one into that static
> array, then does one puts() at the end.
>
> Turns out it's VERY slow for large result sets.
>
> Option 1 Option 2
> substring catt: 91 matches found 0.04s 0.038s
> substring cat : 3710 matches found 0.20s 0.16s
> substring ca : 22793 matches found 1.39s 2.25s
> substring c : 128689 matches found 7.75s 57.91s
> substring e : 252896 matches found 15.29s 216.58s
>
> Option 1 starts printing immediately, one line at a time. Option 2 sits
> there constructing that long string for quite a while. Too long I
> think. What might I be doing wrong?
>
> Note: the timing includes time to print to screen. Just finding the
> word matches is 0.03s using either option.
>
>
> =================================================================
>
> //option 1: one puts per line (suggested by bart)
> int i = 0;
> char buff[longword+3];
> char line[tcols];
> *line = '\0';
> while(i < matchcnt) {
> for(int j = 1;j<=maxcols;j++) {
> sprintf(buff,"%-*s ",longword,matchwords[i++]);
> strcat(line,buff);
> }
> puts(line);
> *buff = '\0';
> *line = '\0';
> }
>
> =================================================================
>
> //option 2: one big string, one puts (per Lurndal)
> static char line[10000000]; //declared outside the func
>
> int i = 0;
> char buff[longword+3];
> *line = '\0';
> while(i < matchcnt) {
> for(int j = 1;j<=maxcols;j++) {
> sprintf(buff,"%-*s ",longword,matchwords[i++]);
> strcat(line,buff);
^^^^^^^^^^^^^^^^^^
> }
> *buff = '\0';
> strcat(line,"\n");
> }
> puts(line);
>
> =================================================================

The 'strcat' in a loop is classic antipattern: it causes quadratic
complexity to to repeated scanning for end of 'line'. Use something
like

char * cp = line;
.....
strcat(cp, buff);
cp += strlen(buff);
....

--
Waldek Hebisch

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

<sf07l7$f56$1@dont-email.me>

  copy mid

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

  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: Wed, 11 Aug 2021 11:09:36 +0100
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <sf07l7$f56$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 11 Aug 2021 10:09:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ebac4182797cc3b1d63c47001b000224";
logging-data="15526"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++yx40veaBaQ1ONlNxmlyNiStkXSJ5pOo="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:IIaa2YShMiK+YFCohdXGHnccAGk=
In-Reply-To: <TEEQI.5686$Ug5.143@fx24.iad>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210810-14, 10/8/2021), Outbound message
 by: Bart - Wed, 11 Aug 2021 10:09 UTC

On 11/08/2021 01:15, DFS wrote:
> On 8/10/2021 6:22 PM, Bart wrote:
>> On 10/08/2021 23:08, DFS wrote:
>>> On 8/10/2021 2:41 PM, Scott Lurndal wrote:
>>
>>>> I was suggesting that the compiler could have just
>>>> stored a 160k string in RO storage and called puts
>>>> with a pointer to it.   There is no need to construct
>>>> it at runtime.
>>>>
>>>> The entire program would reduce to a single call
>>>> to puts with a compiler generated constant string.
>>>
>>> Gotcha.
>>>
>>> I just noticed something in my program.  Using option 2 above, the
>>> version compiled by tcc crashes when the value in line 3 is large
>>> (1027424).  The version compiled by gcc doesn't crash.
>>>
>>> Is that a stack overflow issue?
>>>
>>
>> Yes, you're using VLAs, (maybe in option 1 too if longword and tcols
>> are not compile-time constants).
>
> They're not.  Longword is the longest word (1 to 31) in a result set,
> and tcols is the width of your terminal at the time you do the search.
>
> Here's the app: https://imgur.com/a/cQdvAeM
>
>
>
>> Typical stack size is a few MB. It seems the default stack size of tcc
>> is smaller than of gcc**. tcc crashes with this:
>>
>>      int n=2000000;
>>      char str[n];
>>      memset(str,0,n);
>>
>> but gcc doesn't, until you change n to 4000000. If I dump the two
>> executables, then the gcc one contains this:
>>
>>    Stack reserve:    2097152
>>    Stack commit:     4096
>>
>> tcc's has:
>>
>>    Stack reserve:    1048576
>>    Stack commit:     4096
>>
>> There are probably ways of increasing the stack size, but better not
>> to use VLAs for arrays of this size. (Use static arrays or allocate on
>> the heap.)
>
>
> Thanks.  I created a static array[10_000_000] outside the function, and
> it handled large results sets just fine.  But another issue popped up,
> using option 2, which concatenates words one by one into that static
> array, then does one puts() at the end.
>
> Turns out it's VERY slow for large result sets.

Because each strcat involves scanning the entire string so far to find
its end.

However, this would have been the case using the VLA too, or was it fast
in that case?

Also, the idea of printing just one giant string to the screen is rather
extreme. Longer strings /are/ printed more quickly compared with very
short ones. But dozens are characters long will be sufficient; they
don't need to be millions of characters!

If you do need to construct a string of millions of characters, you
might try keeping track of the current length as antispam suggested.

Or use a resizable buffer as I normally do it, but this gets complicated.

Or write the text to a temporary file (fprintf), then just display the
file (either load it into memory, or simply use system("type filename").

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

<875ywci8k0.fsf@bsb.me.uk>

  copy mid

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

  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: Wed, 11 Aug 2021 11:23:43 +0100
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <875ywci8k0.fsf@bsb.me.uk>
References: <s9iea5$n5c$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad>
<poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad>
<seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad>
<sf021q$78n$1@z-news.wcss.wroc.pl>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="5cec1deac9f4bcbbf715d1b469393f55";
logging-data="19341"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iAtVrFHmG22rPlq3wGpedJWARJaVijRU="
Cancel-Lock: sha1:meW2+6D5psyZKslZ7bBL52x1h5k=
sha1:nPZw4/u0J8pJJTOdXkLE6CkSQlc=
X-BSB-Auth: 1.3b8bfc6181785c9fe771.20210811112343BST.875ywci8k0.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 11 Aug 2021 10:23 UTC

antispam@math.uni.wroc.pl writes:

> DFS <nospam@dfs.com> wrote:
<cut>
>> =================================================================
>>
>> //option 1: one puts per line (suggested by bart)
>> int i = 0;
>> char buff[longword+3];
>> char line[tcols];
>> *line = '\0';
>> while(i < matchcnt) {
>> for(int j = 1;j<=maxcols;j++) {
>> sprintf(buff,"%-*s ",longword,matchwords[i++]);
>> strcat(line,buff);
>> }
>> puts(line);
>> *buff = '\0';
>> *line = '\0';
>> }
>>
>> =================================================================
>>
>> //option 2: one big string, one puts (per Lurndal)
>> static char line[10000000]; //declared outside the func
>>
>> int i = 0;
>> char buff[longword+3];
>> *line = '\0';
>> while(i < matchcnt) {
>> for(int j = 1;j<=maxcols;j++) {
>> sprintf(buff,"%-*s ",longword,matchwords[i++]);
>> strcat(line,buff);
> ^^^^^^^^^^^^^^^^^^
>> }
>> *buff = '\0';
>> strcat(line,"\n");
>> }
>> puts(line);
>>
>> =================================================================
>
> The 'strcat' in a loop is classic antipattern: it causes quadratic
> complexity to to repeated scanning for end of 'line'. Use something
> like
>
> char * cp = line;
> .....
> strcat(cp, buff);
> cp += strlen(buff);
> ....

.... or get the length first and use memcpy. But my favourite is

cp += snprintf(cp, "%s", whatever);

--
Ben.

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

<63773d19-8176-43a0-9c6d-47f72b1e1c10n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:6387:: with SMTP id x129mr16973097qkb.42.1628678779547;
Wed, 11 Aug 2021 03:46:19 -0700 (PDT)
X-Received: by 2002:a37:9dd5:: with SMTP id g204mr26842356qke.229.1628678779410;
Wed, 11 Aug 2021 03:46:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 11 Aug 2021 03:46:19 -0700 (PDT)
In-Reply-To: <875ywci8k0.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad>
<poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad>
<seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad>
<sf021q$78n$1@z-news.wcss.wroc.pl> <875ywci8k0.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <63773d19-8176-43a0-9c6d-47f72b1e1c10n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Wed, 11 Aug 2021 10:46:19 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Wed, 11 Aug 2021 10:46 UTC

On Wednesday, August 11, 2021 at 1:23:55 PM UTC+3, Ben Bacarisse wrote:
> anti...@math.uni.wroc.pl writes:
>
> > DFS <nos...@dfs.com> wrote:
> <cut>
> >> =================================================================
> >>
> >> //option 1: one puts per line (suggested by bart)
> >> int i = 0;
> >> char buff[longword+3];
> >> char line[tcols];
> >> *line = '\0';
> >> while(i < matchcnt) {
> >> for(int j = 1;j<=maxcols;j++) {
> >> sprintf(buff,"%-*s ",longword,matchwords[i++]);
> >> strcat(line,buff);
> >> }
> >> puts(line);
> >> *buff = '\0';
> >> *line = '\0';
> >> }
> >>
> >> =================================================================
> >>
> >> //option 2: one big string, one puts (per Lurndal)
> >> static char line[10000000]; //declared outside the func
> >>
> >> int i = 0;
> >> char buff[longword+3];
> >> *line = '\0';
> >> while(i < matchcnt) {
> >> for(int j = 1;j<=maxcols;j++) {
> >> sprintf(buff,"%-*s ",longword,matchwords[i++]);
> >> strcat(line,buff);
> > ^^^^^^^^^^^^^^^^^^
> >> }
> >> *buff = '\0';
> >> strcat(line,"\n");
> >> }
> >> puts(line);
> >>
> >> =================================================================
> >
> > The 'strcat' in a loop is classic antipattern: it causes quadratic
> > complexity to to repeated scanning for end of 'line'. Use something
> > like
> >
> > char * cp = line;
> > .....
> > strcat(cp, buff);
> > cp += strlen(buff);
> > ....
> ... or get the length first and use memcpy. But my favourite is
>
> cp += snprintf(cp, "%s", whatever);
>
> --
> Ben.

Don't you mean sprintf() ?
snprintf() requires one more parameter (size of the target buffer) and does *not* return the number of actually written characters when buffer is too small.

Pages:12345678910111213141516
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor