Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
├── 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);
#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: []),
name: "SwiftClangCompat",
dependencies: ["CExp"]),
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
You can’t perform that action at this time.