🌗 測試 Swift 與 Raylib 的 C 語言相容性 | 探索狂野指標的旅程
➤ Swift與C語言的無縫融合:以Raylib為例的跨平臺實踐
https://carette.xyz/posts/swift_c_compatibility_with_raylib/
原作者透過將C語言的Raylib遊戲函式庫與Swift結合,展現Swift在C語言相容性方面的強大能力,同時駁斥了關於Swift與C/C++專案互動困難的普遍批評。文章詳述瞭如何在不使用手動外部函式介面(FFI)的情況下,為macOS和WASI平臺建構一個基礎的Raylib遊戲。關鍵步驟包括:妥善組織包含Raylib C語言標頭檔與靜態函式庫的專案結構,在`Package.swift`中配置一個Raylib的Clang目標與一個Swift的可執行目標,以及建立一個至關重要的`module.modulemap`檔案。這個`module.modulemap`檔案扮演著橋樑的角色,讓Swift編譯器的Clang匯入器能自動解析C語言標
#Swift #C語言 #Raylib #WASM #跨平臺開發 #程式語言互通性
Testing the Swift C compatibility with Raylib

Since Ladybird team abandoned their Swift adoption for the browser I heard a lot of criticism about the Swift ecosystem and the interaction between Swift and C/C++ projects. My usage of Swift is mainly for command line tools, recreational programming (like Advent of Code 2023 and previous years) or Metal programming. In my previous experiments I really enjoyed Swift, and actually preferred it to some other programming languages like Rust. However it seems that programmers have wrong opinions about this programming language, especially about its accessibility (no it is not only for Apple platforms) and its actual power wrapping C/C++ libraries.

A journey into a wild pointer