Re: How do you get the OS X version number in C or C++?

2008-11-20 Thread Sean McBride
On 11/15/08 12:40 AM, Michael Ash said:

+ (BOOL)MacOSTigerOrLower
{
 UInt32 version;
 return (Gestalt(gestaltSystemVersion,(SInt32 *) version) ==
noErr)  (version  0x01050 );
}

 Gestalt() is a good approach, but never use gestaltSystemVersion.  See
 Gestalt.h for why.

I don't think you need to never use it. Its failure mode is fairly
benign and completely documented. If you're only interested in
checking for numbers under 9, such as in this case, then it works just
fine.

Well, true enough, but I think my recommendation is still a good idea,
for reasons of style and maintainability.  Someday someone else may need
to change that code.  If one day 10.5.11 is required the codechange is
less straightforward and more error prone.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread chaitanya pandit

+ (BOOL)MacOSTigerOrLower
{
UInt32 version;
return (Gestalt(gestaltSystemVersion,(SInt32 *) version) ==  
noErr)  (version  0x01050 );

}


On 15-Nov-08, at 1:36 AM, Tom Fortmann wrote:

Is there a core foundation function for querying the Mac OS X  
operating
system name and version information?  The uname() API returns the  
Darwin
kernel version information, but I need to find the OS X 10.x.x  
information.




Tom Fortmann

Xcape Solutions

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Randall Meadows

On Nov 14, 2008, at 1:06 PM, Tom Fortmann wrote:

Is there a core foundation function for querying the Mac OS X  
operating
system name and version information?  The uname() API returns the  
Darwin
kernel version information, but I need to find the OS X 10.x.x  
information.


If nothing else, you can use an NSTask to execute sw_vers with the  
appropriate option (which, in this case is -productVersion I think;  
see 'man sw_vers' for details).

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Sean McBride
On 11/15/08 1:48 AM, chaitanya pandit said:

+ (BOOL)MacOSTigerOrLower
{
 UInt32 version;
 return (Gestalt(gestaltSystemVersion,(SInt32 *) version) ==
noErr)  (version  0x01050 );
}

Gestalt() is a good approach, but never use gestaltSystemVersion.  See
Gestalt.h for why.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Jesper Storm Bache
gestaltSystemVersion is not the best way to do it (and it caused  
problems in 10.4.10 and up).

As the documentation in Gestalt.h states:
... A better way to get version information on Mac OS X would be to  
use the new gestaltSystemVersionMajor, gestaltSystemVersionMinor, and  
gestaltSystemVersionBugFix selectors...

Jesper

On Nov 14, 2008, at 12:18 PM, chaitanya pandit wrote:


+ (BOOL)MacOSTigerOrLower
{
UInt32 version;
return (Gestalt(gestaltSystemVersion,(SInt32 *) version) ==
noErr)  (version  0x01050 );
}


On 15-Nov-08, at 1:36 AM, Tom Fortmann wrote:


Is there a core foundation function for querying the Mac OS X
operating
system name and version information?  The uname() API returns the
Darwin
kernel version information, but I need to find the OS X 10.x.x
information.



Tom Fortmann

Xcape Solutions

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/chaitanya%40expersis.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jsbache%40adobe.com

This email sent to [EMAIL PROTECTED]


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


RE: How do you get the OS X version number in C or C++?

2008-11-14 Thread Tom Fortmann
What framework do I include in my Xcode project to pull in Gestalt?  I've
tries CoreServices, Carbon and Cocoa.


-Original Message-
From: Sean McBride [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 14, 2008 2:27 PM
To: chaitanya pandit; Tom Fortmann
Cc: cocoa-dev@lists.apple.com
Subject: Re: How do you get the OS X version number in C or C++?

On 11/15/08 1:48 AM, chaitanya pandit said:

+ (BOOL)MacOSTigerOrLower
{
 UInt32 version;
 return (Gestalt(gestaltSystemVersion,(SInt32 *) version) ==  
noErr)  (version  0x01050 );
}

Gestalt() is a good approach, but never use gestaltSystemVersion.  See
Gestalt.h for why.

-- 

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Nick Zitzmann


On Nov 14, 2008, at 1:53 PM, Tom Fortmann wrote:

What framework do I include in my Xcode project to pull in Gestalt?   
I've

tries CoreServices, Carbon and Cocoa.



It's in the CoreServices umbrella framework, but just linking to the  
Cocoa or Carbon frameworks and importing their master header ought to  
be enough... Are you having trouble getting it to build?


Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Sean McBride
On 11/14/08 2:53 PM, Tom Fortmann said:

What framework do I include in my Xcode project to pull in Gestalt?  I've
tries CoreServices, Carbon and Cocoa.

In Xcode, option-double-click the word Gestalt (or any API), this will
open the docs for that API.  Scroll to the very top, you'll see:

Framework CoreServices/CoreServices.h

That's what you need to include, and that's which framework you should
link to.

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


RE: How do you get the OS X version number in C or C++?

2008-11-14 Thread Tom Fortmann
I'm an idiot!  I was trying to include gestalt.h directly.  Simply including
the CoreService/CoreService.h header works like a champ.


-Original Message-
From: Sean McBride [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 14, 2008 3:17 PM
To: Tom Fortmann; 'chaitanya pandit'
Cc: cocoa-dev@lists.apple.com
Subject: Re: How do you get the OS X version number in C or C++?

On 11/14/08 2:53 PM, Tom Fortmann said:

What framework do I include in my Xcode project to pull in Gestalt?  I've
tries CoreServices, Carbon and Cocoa.

In Xcode, option-double-click the word Gestalt (or any API), this will
open the docs for that API.  Scroll to the very top, you'll see:

Framework CoreServices/CoreServices.h

That's what you need to include, and that's which framework you should
link to.

-- 

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Michael Ash
On Fri, Nov 14, 2008 at 3:27 PM, Sean McBride [EMAIL PROTECTED] wrote:
 On 11/15/08 1:48 AM, chaitanya pandit said:

+ (BOOL)MacOSTigerOrLower
{
 UInt32 version;
 return (Gestalt(gestaltSystemVersion,(SInt32 *) version) ==
noErr)  (version  0x01050 );
}

 Gestalt() is a good approach, but never use gestaltSystemVersion.  See
 Gestalt.h for why.

I don't think you need to never use it. Its failure mode is fairly
benign and completely documented. If you're only interested in
checking for numbers under 9, such as in this case, then it works just
fine.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How do you get the OS X version number in C or C++?

2008-11-14 Thread Rob Keniger


On 15/11/2008, at 6:06 AM, Tom Fortmann wrote:

Is there a core foundation function for querying the Mac OS X  
operating
system name and version information?  The uname() API returns the  
Darwin
kernel version information, but I need to find the OS X 10.x.x  
information.



This is the way you should do it:

SInt32 majorVersion,minorVersion,bugFixVersion;

Gestalt(gestaltSystemVersionMajor, majorVersion);
Gestalt(gestaltSystemVersionMinor, minorVersion);
Gestalt(gestaltSystemVersionBugFix, bugFixVersion);

NSLog(@Running on Mac OS X %d.%d. 
%d,majorVersion,minorVersion,bugFixVersion);


--
Rob Keniger



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]