<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/c-interoperability",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "C Interoperability"
}
-->

# C Interoperability

Use imported C types or call C variadic functions.

## Topics

### C and Objective-C Pointers

[`OpaquePointer`](/documentation/Swift/OpaquePointer)

A wrapper around an opaque C pointer.

[`AutoreleasingUnsafeMutablePointer`](/documentation/Swift/AutoreleasingUnsafeMutablePointer)

A mutable pointer addressing an Objective-C reference that doesn’t own its
target.

### C Variadic Functions

[`withVaList(_:_:)`](/documentation/Swift/withVaList(_:_:))

Invokes the given closure with a C `va_list` argument derived from the
given array of arguments.

[`CVaListPointer`](/documentation/Swift/CVaListPointer)

[`CVarArg`](/documentation/Swift/CVarArg)

A type whose instances can be encoded, and appropriately passed, as
elements of a C `va_list`.

[`getVaList(_:)`](/documentation/Swift/getVaList(_:))

Returns a `CVaListPointer` that is backed by autoreleased storage, built
from the given array of arguments.

### Pointers to Values

Access a pointer to a variable in memory for explicit passing to C functions.

[`withUnsafePointer(to:_:)`](/documentation/Swift/withUnsafePointer(to:_:)-9fjn6)

Invokes the given closure with a pointer to the given argument.

[`withUnsafePointer(to:_:)`](/documentation/Swift/withUnsafePointer(to:_:)-35wrn)

Invokes the given closure with a pointer to the given argument.

[`withUnsafeMutablePointer(to:_:)`](/documentation/Swift/withUnsafeMutablePointer(to:_:))

Calls the given closure with a mutable pointer to the given argument.

[`withUnsafeBytes(of:_:)`](/documentation/Swift/withUnsafeBytes(of:_:)-3ywhh)

Invokes the given closure with a buffer pointer covering the raw bytes of
the given argument.

[`withUnsafeBytes(of:_:)`](/documentation/Swift/withUnsafeBytes(of:_:)-5gesg)

Invokes the given closure with a buffer pointer covering the raw bytes of
the given argument.

[`withUnsafeMutableBytes(of:_:)`](/documentation/Swift/withUnsafeMutableBytes(of:_:))

Invokes the given closure with a mutable buffer pointer covering the raw
bytes of the given argument.

### Aliases for Imported C Types

[`CBool`](/documentation/Swift/CBool)

The C ‘_Bool’ and C++ ‘bool’ type.

[`CChar`](/documentation/Swift/CChar)

The C ‘char’ type.

[`CChar8`](/documentation/Swift/CChar8)

The C++20 ‘char8_t’ type, which has UTF-8 encoding.

[`CChar16`](/documentation/Swift/CChar16)

The C++11 ‘char16_t’ type, which has UTF-16 encoding.

[`CChar32`](/documentation/Swift/CChar32)

The C++11 ‘char32_t’ type, which has UTF-32 encoding.

[`CDouble`](/documentation/Swift/CDouble)

The C ‘double’ type.

[`CLongDouble`](/documentation/Swift/CLongDouble)

[`CFloat`](/documentation/Swift/CFloat)

The C ‘float’ type.

[`CFloat16`](/documentation/Swift/CFloat16)

The C ‘_Float16’ type.

[`CInt`](/documentation/Swift/CInt)

[`CLong`](/documentation/Swift/CLong)

[`CLongLong`](/documentation/Swift/CLongLong)

The C ‘long long’ type.

[`CShort`](/documentation/Swift/CShort)

The C ‘short’ type.

[`CSignedChar`](/documentation/Swift/CSignedChar)

The C ‘signed char’ type.

[`CUnsignedChar`](/documentation/Swift/CUnsignedChar)

The C ‘unsigned char’ type.

[`CUnsignedInt`](/documentation/Swift/CUnsignedInt)

[`CUnsignedLong`](/documentation/Swift/CUnsignedLong)

[`CUnsignedLongLong`](/documentation/Swift/CUnsignedLongLong)

The C ‘unsigned long long’ type.

[`CUnsignedShort`](/documentation/Swift/CUnsignedShort)

The C ‘unsigned short’ type.

[`CWideChar`](/documentation/Swift/CWideChar)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)