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

Re: What's wrong with bluefish?



Barak Pearlmutter <bap@cs.unm.edu> writes:

> According to the C standard, a (char *) can always be cast to a (long int)

Are you sure? I don't think its guranteed anywhere that char* fits in
any type of other variable.

> and back without corruption, but not always to an (int).  With gcc an
> (int) is the same size as a (long int) on the i386, but not on the
> Alpha, which is what is causing problems here.
> 
> To fix it, just redefine the structure slot called "Item 4" below as a
> (long int) rather just a plain (int).  Naturally the change won't make
> any difference at all on an i386...

The proper fix would be an union:

union {
	int   integer;
	char* char_pointer;
}

If the union has no name, you can use the members of that union
directly, otherwise you have to use the same syntax as with structs.
Of cause you should never write an int to the union and read a char*
from it, since that is not defined to have a proper result.

May the Source be with you.
			Goswin


Reply to: