Deutsch   English   Français   Italiano  
<fPmcnaKaU81_TsP1nZ2dnZfqn_adnZ2d@giganews.com>

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

Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!local-4.nntp.ord.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 27 Jun 2025 17:24:50 +0000
Subject: Re: VMS
Newsgroups: comp.os.linux.misc
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>
 <wwv4iw1bpor.fsf@LkoBDZeT.terraraq.uk>
From: c186282 <c186282@nnada.net>
Date: Fri, 27 Jun 2025 13:24:06 -0400
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
 Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <wwv4iw1bpor.fsf@LkoBDZeT.terraraq.uk>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Message-ID: <fPmcnaKaU81_TsP1nZ2dnZfqn_adnZ2d@giganews.com>
Lines: 50
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-zorsRCkOC3tQS6EAD97FYbtXfgvoDY30rxyit/Xp3mf/hBL1xMQbeiy/ItJebLqeX6phuy4pXNIHUAy!JDgCYXNDnS7Ef31IYcI3MrYliLAkDD2vBFAqFbh/tuN0JYM8z1pzgWUyb1TuX/3849Bk77x8FrJ7
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40

On 6/27/25 3:37 AM, Richard Kettlewell wrote:
> 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.

   "Best practice" sometimes means a little bit of
   redundant/clarifying code.

   Some of us are old enough to remember when CPUs were
   not always 4/8/16/32/64 ... plus even now they've
   added a lot of new types like 128-bit ints. Simply
   ASSUMING an int is 16 bits is 'usually safe' but
   not necessarily 'best practice' and limits future
   (or past) compatibility. 'C' lets you fly free ...
   but that CAN be straight into a window pane  :-)