Re: Comparisons and Operations on BigEndianLong
Re: Comparisons and Operations on BigEndianLong
- Subject: Re: Comparisons and Operations on BigEndianLong
- From: Rua Haszard Morris <email@hidden>
- Date: Fri, 22 Sep 2006 10:15:20 +1200
We wrote accessor wrapper funcs to deal with types like that...
inline long BigEndianLong_GetValue(BigEndianLong const& val)
{
#if TARGET_RT_LITTLE_ENDIAN
return val.bigEndianValue;
#else
return val;
#endif
};
This function would take care of the platform difference in the type,
but leave it Big-Endian for the calling code to swap if it needed to.
So your code would be:
if ( BigEndianLong_GetValue(theKeys[1]) & EndianU32_NtoB
(0x00000001) )
{
return( true );
}
(I think)
have fun
On 22/09/2006, at 9:59 AM, Jeff Birac wrote:
I'm a newbie to Universal development. How do I deal (universally)
with BigEndianLong values?
The following code (compiled fine for PPC) is meant to check if the
Shift key is pressed. But the compiler (for i386) complains
"error: no match for 'operator&' in 'theKeys[1] & 1'."
Boolean IsShiftKeyPressed()
{
KeyMap theKeys;
::GetKeys( theKeys );
if ( theKeys[1] & 0x01 )
{
return( true );
}
return( false );
}
Events.h defines KeyMap...
typedef BigEndianLong KeyMap[4];
Endian.h defines BigEndianLong...
struct BigEndianLong {
long bigEndianValue;
};
typedef struct BigEndianLong BigEndianLong;
So how would some Universal code check the first bit (masked 0x01)
of the second member of the KeyMap theKeys[1] from the GetKeys()
function?
Thanks in advance.
-- Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40adinstruments.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden