[Mono-osx] Interop 32/64 bit check

McKinnon Chris crmckinnon at shaw.ca
Mon Mar 31 22:13:37 UTC 2014


Hi,

I’m writing interop code for Core Foundation on Mac OS X.  I’m curious if anyone has suggestions on how to determine when you are running 32/64 bit in Mono.  I’d like to write my interop code so that it can handle both cases or at least can be compiled for each case.

Here’s an example, in CFBase.c:

#if __LLP64__
typedef signed long long CFIndex;	// CFIndex is 64 bits.
#else	
typedef signed long CFIndex;		// CFIndex is 32 bits.
#endif

If I want to handle this in C#, say for a CFRange which has two CFIndex values, like so:

#if (CF_IS_64_BIT)	// <— are there any defined constants for this?
long location;
long length;
#else
int location;
int length;
#endif

Is there a defined value in Mono to determine if the system is 32 bit versus 64 bit?  Are there better ways to handle this?  I wanted to avoid IntPrs as the code would get messy quick.

Thanks,

Chris McKinnon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-osx/attachments/20140331/97ba9ba2/attachment.html>


More information about the Mono-osx mailing list