Checking the host OS

JB sundown at pacifier.com
Sat Aug 31 02:47:28 EDT 2019


Below is some c code that will return the architecture on
OS X.

/*  Determine the machine name, e.g. "x86_64". */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/sysctl.h>

int main(int argc, const char * argv[]) {
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);  // Get size of data to be returned.
    char *name = malloc(size);
    sysctlbyname("hw.machine", name, &size, NULL, 0);
    
    // Do stuff...
    printf("%s\n", name);
    free(name);
    
    return 0;
}


/*
 Output:
 
 x86_64
 Program ended with exit code: 0
*/

Compile the above code and access it with a shell command.

JB


> On Aug 30, 2019, at 8:41 PM, Devin Asay via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> On Aug 30, 2019, at 9:10 PM, Mark Wieder via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>>> On 8/30/19 12:22 PM, Devin Asay via use-livecode wrote:
>>> 
>>> Now that we can build both 32 and 64 bit applications for Windows, it’s important to be able to tell whether the host OS is 32 or 64 bit.
>> 
>> Why? If the 64-bit application won't run on the 32-bit system you won't get as far as your scripted test. Am I missing something?
> 
> No, I’m just toying with the idea of having a 32-bit launcher that would examine the host OS, then launch the proper executable based on whether it is 32 or 64 bit. Sort of like a poor man’s universal app like we used to create for MacOS. It’s possible I’m use way overthinking this. 
> 
> -D
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list