Sujet : Re: Regarding assignment to struct
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.lang.cDate : 04. May 2025, 10:25:08
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <vv7bpk$2n9mf$1@news.xmission.com>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <
vv6ng8$1410m$1@dont-email.me>,
James Kuyper <
jameskuyper@alumni.caltech.edu> wrote:
...
The fact that an implementation does not have to do the equivalent of
memcpy() to perform a struct copy means that successful assignment
cannot be checked by using memcmp().
Which then begs two questions:
1) Why wouldn't an implementaton do it with memcpy()? That is likely
to be as good or better than any other method, including, especially, a
member-by-member copy.
2) Why wouldn't you, the programmer, just use memcpy() instead of
struct assignment? Yes, I realize there are other cases to consider,
but in the simple one:
struct something foo,bar;
foo = bar;
memcpy() seems like it would always be easier and more reliable.
-- The randomly chosen signature file that would have appeared here is more than 4lines long. As such, it violates one or more Usenet RFCs. In order to remainin compliance with said RFCs, the actual sig can be found at the following URL: http://user.xmission.com/~gazelle/Sigs/Pedantic