[Mono-osx] #define and Operating System Specific Code

Andrew Ayre andy at britishideas.com
Wed Oct 12 11:51:04 EDT 2011


On 10/12/2011 4:07 PM, Bojan Rajkovic wrote:
> 
> On Oct 12, 2011, at 10:52 AM, Andrew Ayre wrote:
> 
>> Hi, where can I find a list of compiler defines that Mono provides to
>> identify the current operating system?
>>
>> Thanks, Andy
>>
>> -- 
>> Andy
>> PGP Key ID: 0xDC1B5864
> 
> Hi Andy,
> 
> The answer is you don't. The Mono compiler does not provide any defines to identify the current operating system. Depending on what you need to do, you may want to use something like Environment.OperatingSystem, or if you need to make a distinction between OS X and Linux/Unix, go deeper and P/Invoke uname(2). Why exactly do you need to differentiate between the OSes?
> 
> —Bojan

Something like:

#if OSX
  public class Foo : NSObject
#else
  public class Foo
#endif

I know I can define OSX in the project settings but I wanted something a
bit less error-prone than having to rely on my memory to add that into
new projects.

Andy

-- 
Andy
PGP Key ID: 0xDC1B5864


More information about the Mono-osx mailing list