Re: IOConnectCallStructMethod which macros for 10.6
Re: IOConnectCallStructMethod which macros for 10.6
- Subject: Re: IOConnectCallStructMethod which macros for 10.6
- From: Steve Checkoway <email@hidden>
- Date: Tue, 22 Nov 2011 14:28:55 -0800
On Nov 22, 2011, at 10:17 AM, kiran kumar wrote:
> i want to use single sourcecode for 10.4 ,10.5, 10,6, 10.7 for that can i use like this
>
> #if define(__LP64__)
> IOConnectCallStructMethod(); //true if it is 10.6(32/64)
> #else
> IOConnectMethodStructureIStructureO(); //10.5, 10.4
> #endif
>
> is this right way can anyone suggest.
If I understand you correctly, you want to have the code run on 10.4 through 10.7 and call different functions based on which version of the OS the code is running on.
If that's true, then your code above is incorrect for two reasons. First, __LP64__ is going to be defined for code compiled for a 64 bit architecture (longs and pointers are 64 bits). It has nothing to do with OS version:
steve$ gcc -dM -x c - -E <<<''|grep LP64
#define __LP64__ 1
#define _LP64 1
steve$ gcc -dM -x c - -E -arch i386 <<<''|grep LP64
Note that the second command outputs nothing.
The second reason this is incorrect is that this is using one function or another at compile time, not run time.
Looking at the headers for those functions, IOConnectCallStructMethod() is explicitly documented as working with LP64 and ILP32 and it appeared in 10.5. IOConnectMethodStructureIStructure0() appeared in 10.0 but was deprecated in 10.5 and does not work with LP64.
So it sounds like you should call the latter for 10.4 and the former for 10.5 and above.
Something like:
#if defined(__LP64__)
IOConnectCallStructMethod(...); // 64 bit
#else
if (&IOConnectCallStructMethod != NULL)
IOConnectCallStructMethod(...); // 10.5 or later
else
IOConnectMethodStructureIStructure0(...); // 10.4
#endif
And for this, you need MAC_OS_X_VERSION_MIN_REQUIRED defined to MAC_OS_X_VERSION_10_4.
--
Steve Checkoway
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden