Gestalt
Gestalt Get information about the operating environment
#include <GestaltEqu.h> Gestalt Manager
OSErr Gestalt( selector, response );
OSType selector ; Gestalt selector code
long *response ; 4-byte return result
returns Error Code; 0=no error
Gestalt provides your application with information about specific hardware
and software features.
selector is either a pre defined code or an application- defined code
requesting information on a specific hardware or software feature
(see Using the Gestalt Manager for a list of selector codes).
response is the return value that provides the requested
information. Gestalt must already recognize the selector parameter
in order to return a response.
Returns: an operating system Error Code.
It will be one of:
noErr (0) No error
gestaltUnknown (-5550) Could not obtain the response
gestaltUndefSelectorErr (-5551) Un defined selector

Notes: Gestalt returns the results from all function selectors in a 4-byte long
integer. Where not all 4 bytes are needed, the result is expressed in the
low-order bytes.
Being passed a pre defined selector code doesn't cause Gestalt to move or
purge memory and therefore may be called even at interrupt time.
However, application- defined selector codes may move or purge memory
and applications can alter Gestalt's pre defined selector functions. Given
all of that, you should always assume that Gestalt might always move or
purge memory.
THINK C 5.0 or later, THINK Pascal 4.0 or later and MPW 3.2 or later
contain glue that make it possible to call Gestalt under System versions
which do not support Gestalt (earlier than System 6.0.4). When possible,
the glue will call other traps in order to obtain the information requested.
If the selector is not available, a gestaltUndefSelectorErr will be returned.
Note that if you are programming in assembly language, this glue is not
provided. The following selectors are made available by this glue:
gestaltVersion
gestaltMachineType
gestaltSystemVersion
gestaltProcessorType
gestaltFPUType
gestaltQuickdrawVersion
gestaltKeyboardType
gestaltAppleTalkVersion
gestaltMMUType
gestaltPhysicalRAMSize
gestaltLogicalRAMSize
All other selectors will return a gestaltUndefSelectorErr under System
versions which do not support Gestalt..
See Using the Gestalt Manager for additional sample code which
demonstrates the use of Gestalt.
Example
#include
#include
static char * processor[] = {
"",
"mc68000",
"mc68010",
"mc68020",
"mc68030",
"mc68040
};
static char *fpu[] = {
"",
"mc68881",
"mc68882",
"mc68040 built-in
};
main ()
{
long gestaltAnswer;
OSErr gestaltErr;
/* Determine whether we can use Gestalt or not, and if so, what version */
gestaltErr = Gestalt ( gestaltVersion, & gestaltAnswer);
if (! gestaltErr) {
printf ("Gestalt is available, version %ld\n", gestaltAnswer);
printf ("\n");
/* Determine the processor type */
Gestalt ( gestaltProcessorType, & gestaltAnswer);
if ( gestaltAnswer > 5) /* A constant for a processor we don't */
/* recognize has been returned */
printf ("Processor type: %s\n", processor[0]);
else
printf ("Processor type: %s\n", processor[ gestaltAnswer]);
/* Determine the coprocessor type */
Gestalt ( gestaltFPUType, & gestaltAnswer);
printf ("FPU type: %s\n", fpu [ gestaltAnswer]);
} else
printf ("Gestalt not available\n");
}