Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sources/
├── CExp
│   ├── include
│   │   └── c_exp.h
│   └── shim.c
└── SwiftClangCompat
└── main.swift
#ifndef C_EXP_H
#define C_EXP_H
#include <stdio.h>
void POSIX_print(char *string);
#endif
#include <c_exp.h>
#include <stdio.h>
void POSIX_print(char *string) {
printf("%s\n", string);
}
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "SwiftClangCompat",
dependencies: [],
targets: [
.target(name: "CExp", dependencies: []),
.target(
name: "SwiftClangCompat",
dependencies: ["CExp"]),
.testTarget(
name: "SwiftClangCompatTests",
dependencies: ["SwiftClangCompat"]),
]
)
import Foundation
import CExp
let string = "(☝՞ਊ ՞)☝ウェーイwww "
string.withCString { (strPtr: UnsafePointer<Int8>) -> Void in POSIX_print(UnsafeMutablePointer(mutating: strPtr)) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment