Deutsch   English   Français   Italiano  
<wwv4iw1bpor.fsf@LkoBDZeT.terraraq.uk>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: Richard Kettlewell <invalid@invalid.invalid>
Newsgroups: comp.os.linux.misc
Subject: Re: VMS
Date: Fri, 27 Jun 2025 08:37:24 +0100
Organization: terraraq NNTP server
Message-ID: <wwv4iw1bpor.fsf@LkoBDZeT.terraraq.uk>
References: <wCqdnYde9MIbmND1nZ2dnZfqnPadnZ2d@giganews.com>
	<87tt4i9nw5.fsf@eder.anydns.info> <102l0h9$fjtb$5@dont-email.me>
	<Z2udned3u9ZgqtP1nZ2dnZfqnPudnZ2d@giganews.com>
	<slrn1054j9c.3ce8.candycanearter07@candydeb.host.invalid>
	<PpudnVnCnvuYxc_1nZ2dnZfqnPudnZ2d@giganews.com>
	<wwva564xjps.fsf@LkoBDZeT.terraraq.uk>
	<4_GdncCsf-Nqe8n1nZ2dnZfqnPSdnZ2d@giganews.com>
	<wwv5xgqkfl9.fsf@LkoBDZeT.terraraq.uk> <103392c$lpbg$5@dont-email.me>
	<1033o4a$1qj6$3@dont-email.me> <1033tv1$3aqu$3@dont-email.me>
	<1034pj8$a74s$1@dont-email.me> <mbmm2nFdsgcU2@mid.individual.net>
	<slrn105cajs.4vj.spamtrap42@one.localnet>
	<slrn105g20l.3q8n7.candycanearter07@candydeb.host.invalid>
	<slrn105k75h.h13.spamtrap42@one.localnet>
	<slrn105sci1.1ibsg.candycanearter07@candydeb.host.invalid>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
	logging-data="61330"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Lh2LvfJVaSmPKhqTEtN1n2rdMBo=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
     F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
     +r0NzP?vnz:e/knOY)PI-
X-Boydie: NO

candycanearter07 <candycanearter07@candycanearter07.nomail.afraid>
writes:
> Robert Riches <spamtrap42@jacob21819.net> wrote at 03:34 this Tuesday (GMT):
>> <candycanearter07@candycanearter07.nomail.afraid> wrote:
>>> Aren't you supposed to multiply by sizeof as well?
>>
>> Multiply by sizeof what?  sizeof(char)?  This was in the
>> pre-Unicode days.  Even now with Unicode, IIUC sizeof(char) is
>> still always 1.
>
> I still multiply by sizeof(char), half because of habit and half to
> make it clear to myself I'm making a char array, even if its
> "redundant". I kinda thought that was the "cannonical" way to do that,
> since you could have a weird edge case with a system defining char as
> something else?

Whatever the representation of char, sizeof(char)=1. That’s what the
definition of sizeof is - char is the unit it counts in.

From the language specification:

    When sizeof is applied to an operand that has type char, unsigned
    char, or signed char, (or a qualified version thereof) the result is
    1. When applied to an operand that has array type, the result is the
    total number of bytes in the array.) When applied to an operand that
    has structure or union type, the result is the total number of bytes
    in such an object, including internal and trailing padding.

A programmer can adopt a personal style of redundantly multiplying by 1
if they like, it’ll be a useful hint to anyone else reading the code
that the author didn’t know the language very well. But in no way is
anyone ‘supposed’ to do it.

-- 
https://www.greenend.org.uk/rjk/