On Mac OS X, what does the function gestalt do? What is it used for? Could you please give a brief example? I know that it has something to do with system calls, but what exactly?
Gestalt gives you details about the system the application is running on, such as the OS version. Here is a simple example to get the Mac OSX version on the system this binary is run:
#include <stdio.h>
#include <Gestalt.h>
int main() {
SInt32 versMaj, versMin, versBugFix;
Gestalt(gestaltSystemVersionMajor, &versMaj);
Gestalt(gestaltSystemVersionMinor, &versMin);
Gestalt(gestaltSystemVersionBugFix, &versBugFix);
printf("Mac Version: %d.%d.%d\n", versMaj, versMin, versBugFix);
}
compile and run this test with:
gcc -framework Carbon test.c && ./a.out
You may aslo need a flag like -I/Developer/Headers/FlatCarbon/
This should give a response like: Mac Version: 10.6.8
I created this example after reading the official docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With