home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- From: jes@grendel.demon.co.uk (Jim Segrave)
- Path: sparky!uunet!pipex!demon!grendel.demon.co.uk!jes
- Distribution: world
- Subject: How is struct assignment defined (idle query)?
- X-Mailer: cppnews $Revision: 1.14 $
- Organization: None
- Lines: 27
- Date: Thu, 3 Sep 1992 12:13:26 +0000
- Message-ID: <715547606snx@grendel.demon.co.uk>
- Sender: usenet@gate.demon.co.uk
-
-
- I don't have access to a copy of the ANSI spec, hence my query:
-
- Does ANSI say that structure assignment is done by member-wise copy or
- by bit-wise copying?
- The reason I ask is that if it is a bit-wise copy, then any padding in
- a struct would have to have some (presumably inplementation defined)
- value written to it so that the padding bytes could be copied.
- I realise that most implementations will not suffer any ill effects
- from the notional conversion of the following assignment:
-
- struct a {...} a_one = { ...};
- int some_func ()
- {
- struct a a_two = a_one;
-
-
- to:
- memcpy ((void *) &a_two, (void *) &a_one, sizeof (struct a));
-
- but I wondered if this conveys the actual ANSI definition of struct
- assignment.
-
-
- --
- Jim Segrave
-
-