Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #142811
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: memcpy or assign data to uint64 on little endian(linux) system |
| Date | 2019-04-03 12:50 -0700 |
| Organization | None to speak of |
| Message-ID | <lnk1ga98cu.fsf@kst-u.example.com> (permalink) |
| References | <3b06fd96-348b-423c-af57-e44e1f79b40c@googlegroups.com> <slrn3orcqa9mnj.mo9.ike@iceland.freeshell.org> |
Ike Naar <ike@iceland.freeshell.org> writes:
> On 2019-04-03, WalkeR Park <walker.ykpark@gmail.com> wrote:
[...]
>> uint64 a;
>> char b[8] = {0x38, 0x12, 0x12, 0x12, 0x81, 0x28, 0x28, 0x28};
>
> Perhaps you want to change that into
>
> unsigned char b[8] = {0x38, 0x12, 0x12, 0x12, 0x81, 0x28, 0x28, 0x28};
>
> because, on a platform where char is signed, e.g. 0x81 will not fit.
Agreed.
It's very likely that the version with plain char will work, because the
implementation-defined conversion from unsigned char to plain char
almost certainly preserves the bit pattern, but using unsigned char
removes that very minor uncertainty.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
memcpy or assign data to uint64 on little endian(linux) system WalkeR Park <walker.ykpark@gmail.com> - 2019-04-02 18:14 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Geoff <geoff@invalid.invalid> - 2019-04-02 22:49 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Ike Naar <ike@iceland.freeshell.org> - 2019-04-03 06:14 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system Geoff <geoff@invalid.invalid> - 2019-04-02 23:22 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-03 11:07 +0100
Re: memcpy or assign data to uint64 on little endian(linux) system Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-04-03 12:56 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system fir <profesor.fir@gmail.com> - 2019-04-03 06:52 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-04-03 16:06 +0100
Re: memcpy or assign data to uint64 on little endian(linux) system fir <profesor.fir@gmail.com> - 2019-04-03 04:03 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system fir <profesor.fir@gmail.com> - 2019-04-03 04:13 -0700
Re: memcpy or assign data to uint64 on little endian(linux) system Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-04-03 12:37 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system Ike Naar <ike@iceland.freeshell.org> - 2019-04-03 16:10 +0000
Re: memcpy or assign data to uint64 on little endian(linux) system Keith Thompson <kst-u@mib.org> - 2019-04-03 12:50 -0700
csiph-web