Predefined Versions for Apple Operating Systems

Sergey kornburn at yandex.ru
Sun Jun 22 13:09:54 UTC 2025


On Sunday, 22 June 2025 at 00:44:42 UTC, Jonathan M Davis wrote:
>
> As for Darwin or whether we need `__APPLE__` (or whatever we 
> call it) as a replacement, well, I'm not familiar enough with 
> Apple's OSes to weigh in on that.
>
> - Jonathan M Davis

Maybe in that case we can fix all other versions as well..
And just some examples from other langs (from gpt)

```rust
use std::env;

fn main() {
     let os = if cfg!(target_os = "linux") {
         "linux"
     } else if cfg!(target_os = "macos") {
         "macos (Darwin)"
     } else if cfg!(target_os = "ios") {
         "ios (Darwin)"
     } else if cfg!(target_os = "windows") {
         "windows"
     } else {
         "unknown"
     };

     println!("Running on: {}", os);
}
```

Rust: all small letters - consistent

```swift
import Foundation

func getOSName() -> String {
     #if os(Linux)
     return "linux"
     #elseif os(macOS)
     return "macos (Darwin)"
     #elseif os(iOS)
     return "ios (Darwin)"
     #else
     return "unknown"
     #endif
}

print("Running on: \(getOSName())")
```

Swift: playing with all proper names (see Linux with capital)

```go
package main

import (
	"fmt"
	"runtime"
)

func main() {
	os := runtime.GOOS
	var osName string

	switch os {
	case "linux":
		osName = "linux"
        case "ios":
                 osName = "darwin (iOS)"
	case "darwin":
		osName = "darwin (macOS)"
	default:
		osName = "unknown"
	}

	fmt.Printf("Running on: %s\n", osName)
}
```

Go: all small letters as well ("ios" support is a bit cumbersome 
though)

Consistency everywhere


More information about the Digitalmars-d mailing list