본문 바로가기
#모바일 [Mobile]/iOS

[iOS] Swift C/C++ Language Type (C/C++ Interoperability)

by cy_mos 2020. 7. 18.
반응형
카테고리 (Category) 작성 날짜 (Write Date) 최근 수정 날자 (Recent Write Date) 작성자 (Writer)
iOS 2020.07.18. 13:11 2021.10.31. 21:08:59 Dev.Yang

 

🗂 Swift Lanuage C/C++ Interoperability Type

C Language Data Type Swift (C Interoperability) Type Typealias 
bool CBool Bool
char,unsigned char CChar, CUnsignedChar Int8, UInt8
short, unsigned short CShort, CUnsignedShort Int16, UInt16
int, unsigned int CInt, CUnsignedInt Int32, UInt32
long, unsigned long CLong, CUnsignedLong Int, UInt
long long, unsigned long long CLongLong, CUnsignedLongLong Int64, UInt64
wchar_t, char16_t, char32_t CWideChar, CChar16, CChar32 UnicodeScalar, UInt16, UnicodeScalar
float, double CFloat, CDouble Float, Double

🗂 Swift Lanuage C/C++ Interoperability Description

🏷 CBool

  • The C ‘_Bool’ and C++ ‘bool’ type.
typealias CBool = Bool

🏷 CChar

  • The C ‘char’ type. This will be the same as either CSignedChar (in the common case) or CUnsignedChar, depending on the platform.
typealias CChar = Int8

🏷 CChar16

  • The C++11 ‘char16_t’ type, which has UTF-16 encoding.
typealias CChar16 = UInt16

 

🏷 CChar32

  • The C++11 ‘char32_t’ type, which has UTF-32 encoding.
typealias CChar32 = Unicode.Scalar

🏷 CDouble

  • The C ‘double’ type.
typealias CDouble = Double

 

🏷 CFloat

  • The C ‘float’ type.
typealias CFloat = Float

🏷 CInt

  • The C ‘int’ type.
typealias CInt = Int32

 

🏷 CLong

  • The C ‘long’ type.
typealias CLong = Int

 

🏷 CWideChar

  • The C++ ‘wchar_t’ type.
typealias CWideChar = Unicode.Scalar

🏷 CLongLong

  • The C ‘long long’ type.
typealias CLongLong = Int64

🚀 REFERENCE

 

Swift And C: Everything You Need to Know on Types, Pointers and more

Now that Swift is available on Linux and other OSes, there are even more situations where you could need to interact with C code from your Swift 3 application. This article will hopefully shed some light on the most non-obvious details and give you some pr

www.uraimo.com

 

Apple Developer Documentation

 

developer.apple.com

반응형

댓글