Re: portability question



One of the other large assumptions that glib makes is about struct alignment. It assumes that if you have

struct fred {
	int a;
};

struct jim {
	struct fred foo;
	int b;
};

You can do
	struct jim *jim = ...;

	((struct fred *) jim)->a = 12;

ie. struct members don't move about strangely.
Like some of the other assumptions you talked about, the justification is that it works for all platforms people care about, and makes code much simpler.

On Tue, 2003-12-16 at 02:15, Sheldon Simms wrote:
I just started reading some of the GLib source code
for the first time and I have noticed that the code
often makes "nonportable" assumptions about the C
implementation like arbitrary pointer/int
interchangability, twos-complement representation of
negative integers, "all-zeros" representation of a
null pointer.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]