gnustep-dev
[Top][All Lists]
Advanced

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

Re: NSControls failing to set status/label on BigEndian/64bit


From: Wolfgang Lux
Subject: Re: NSControls failing to set status/label on BigEndian/64bit
Date: Wed, 6 Jan 2021 22:57:39 +0100

Hi Riccardo,

> good catch. We have two differences here 32bit vs 64bit, but also signed vs 
> unsigned!

the difference between signed and unsigned is irrelevant for encoding and 
decoding, as you pass a pointer to the memory being encoded or decoded. 
However, the size of the value you want to encode or decode should agree with 
the type that is used for coding.

> The first thing I tried was to use NSInteger/NSUInteger as approriate in 
> encodeWithCode and initWithCoder, but Gorm files fail to load
> "Exception occurred while loading model: expected long long and got unsigned 
> int"
> 
> I then tried just to use int to match NSInteger and reduce the signedness 
> problem, then I get insted
> "Exception occurred while loading model: expected int and got unsigned int"

Yes. Changing the type you pass to the {en,de}codeValueOfObjCType methods is a, 
errm, not so bright idea. The types are included in the binary archives. So, 
trying to decode a value with a different type will give you an error (for your 
own safety and sanity). Trying to encode values with a different type is even 
worse, as you would be creating archives that cannot be read by anybody else 
(because they are expecting some other type). If you (have to) make such 
changes, be sure to introduce a new archive version and be sure to include 
backward compatibility code for reading the old archive format.

Wolfgang


reply via email to

[Prev in Thread] Current Thread [Next in Thread]