From: Humm <hummsmith42@gmail.com>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] void*
Date: Sun, 15 May 2022 12:11:35 +0000 [thread overview]
Message-ID: <YoDt933lrx5WKj84@beryllium.local> (raw)
In-Reply-To: <a133ada-4f54-c8a5-7530-9949aa5b45a4@SDF.ORG>
>one of the first thing I noticed compiling in plan9 is that arithmetic
>on void* is illegal.
That’s what the standard says.
While Plan 9 C doesn’t pretend to be compliant, the core language does
roughly match C89 with a few C99 extensions.
>Other compilers treat void* as uchar*. Conceptually, it makes sense.
>A pointer to void doesn't point to any object. But then I've seen the
>use of void* in functions (like memccpy) when the pointed object is
>going to be processed as a byte array. Local uchar*'s are used to do
>the trick inside the function.
>
>It wouldn't make more sense to avoid the use of void* and just use
>instead uchar* or better still u8int*?
(Those are different. On Plan 9, we do make (too many) assumptions
about type sizes, but conceptually, a byte need not be limited to eight
bit.)
I’m now quoting the C99 Rationale (revision 5.10).
Page 37, § 6.2.5:
>A pointer to void must have the same representation and alignment as
>a pointer to char; the intent of this rule is to allow existing
>programs that call library functions such as memcpy and free to
>continue to work.
Page 48, § 6.3.2.3:
>The use of void* (“pointer to void”) as a generic object pointer type
>is an invention of the C89 Committee. Adoption of this type was
>stimulated by the desire to specify function prototype arguments that
>either quietly convert arbitrary pointers (as in fread) or complain if
>the argument type does not exactly match (as in strcmp).
--
Humm
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tecaea3b9ec8e7066-Me2a3b163527df44b207e4fc3
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
next prev parent reply other threads:[~2022-05-15 12:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-15 10:58 adr
2022-05-15 12:11 ` Humm [this message]
2022-05-15 13:03 ` adr
2022-05-15 13:15 ` adr
2022-05-15 13:21 ` arnold
2022-05-15 14:09 ` adr
2022-05-15 14:47 ` ori
2022-05-15 15:49 ` adr
2022-05-15 15:23 ` Dan Cross
2022-05-15 15:50 ` Bakul Shah
2022-05-15 15:54 ` ori
2022-05-15 14:46 ` ori
2022-05-15 16:07 ` adr
2022-05-16 6:24 ` Skip Tavakkolian
2022-05-16 12:46 ` Humm
2022-05-16 13:23 ` Bakul Shah
2022-05-16 14:46 ` Charles Forsyth
2022-05-16 16:03 ` adr
2022-05-16 17:45 ` hiro
2022-05-17 4:00 ` Lucio De Re
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YoDt933lrx5WKj84@beryllium.local \
--to=hummsmith42@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).