Created
September 8, 2024 18:09
-
-
Save dgalling/a697ef26e33180d1d197d8e9c9956113 to your computer and use it in GitHub Desktop.
Simple C interop example in swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int add(int a, int b) { | |
return a + b; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int add(int a, int b); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
swiftc -import-objc-header add.h add.c doit.swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let result = add(1, 1) | |
print("\(result)") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment