Author: Dieter Buerssner
Date: 11:30:41 05/12/03
Go up one level in this thread
The original question was: "Is there any specific order in which the chars are aligned into the int, or is it compiler-dependent?" The discussion evolved around this question did at parts not touch the question at all. From my reading it mainly touched another question: Is the order of structure members defined? The answer is: It is not only compiler dependent, it is even totally out of the C-Standard. In Standard-C, one just cannot do union tricks, where one stores one value in a union and convieniently gets out some other members. On many implementations, one can reliably do it. But the code will not be portable. In Standard C, unions are still useful, but not for such tricks. And about padding bits, etc. In an array of unsigned chars (chars alone are not enough), there will be no padding bits. I think, there is not much more guarantee in Standard C. Regards, Dieter PS. That I answered to your specific post is mor or less coincidence. It does not imply, that you did not understand this well. Just my thought, after reading the whole discussion.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.