I would like to know if a struct in Swift has any guarantee of
contiguity, like a struct in C. I am attempting to port a C program
that makes many assumptions about the underlying semantics of C structs,
and does things like overlaying an array over the struct using a cast,
and then performs a
I have been told that the in-memory layout of a Swift struct is
'undefined', so the C style of aliasing an array over a struct and
iterating across the struct is a definite no-no. Not surprising, since
aliasing violates all type-safe rules.
So, if you have this situation, you must address it
On 2016-05-20 08:55, Jens Alfke wrote:
On May 20, 2016, at 7:33 AM, Ken Burgett via swift-users
wrote:
the required C struct morphs into a Swift class, with a member
function 'as_C_byte_array' which answers an array of the required
form. Internally, this function will shift and
Hi Joe,
Can you point me to a good example of how to build a Swift 3.0 module
that wraps some C code? I have searched, but keep finding Swift 2.2
documentation and it all seems to involve connecting to Objective-C,
while my interests are accessing C code on a Linux platform, using the
latest
I have a large 2D table defined within a C .h file, as follows:
static const uint8_t blake2b_kat[256][64] =
{
{
0x78, 0x6A, 0x02, 0xF7, 0x42, 0x01, 0x59, 0x03,
0xC6, 0xC6, 0xFD, 0x85, 0x25, 0x52, 0xD2, 0x72,
0x91, 0x2F, 0x47, 0x40, 0xE1, 0x58, 0x47, 0x61,
0x8A, 0x86, 0xE2, 0x17,
I tried build a system module, following the cpp and swift variant
mentioned here
(http://ankit.im/swift/2016/05/21/creating-objc-cpp-packages-with-swift-package-manager/).
I hope the author will answer in detail, but I would like to know what
produces the 'error: NoSources(..)' error message?
I really shouldn't have to ask this question for a variety of other
languages, but print format conversion in Swift a black box to me.
I wish to print a 64-bit unsigned integer as 8 hexadecimal digits, and I
can't find any documentation on this. Please advise.
--
Ken Burgett
Principal Softwa
On 2016-05-25 12:00, Jens Alfke wrote:
On May 25, 2016, at 11:11 AM, Ken Burgett wrote:
the "%llx" field is not getting interpreted...
You have to import Foundation to bring in the String.init(format:…)
method, which is bridged from Foundation's NSString class.
(This is a temporary inconvenie
Hi all,
I am trying to understand how Swift 3 File I/O works in a linux
environment. I put together a trivial test program using what I
can glean from the few examples I can find. See below.
===
import Glibc
import Foundation
let filename = Process.arguments[1]
l
t Glibc
let path = "./sample.txt"
let BUFSIZE = 1024
let fp = fopen(path, "r")
if fp != nil {
var buf = [CChar](count:BUFSIZE, repeatedValue:CChar(0))
while fgets(&buf, Int32(BUFSIZE), fp) != nil {
print(String.fromCString(buf)!, terminator:"")
}
}
K
le text file I/O with Swift 3
Message-ID:
Content-Type: text/plain; charset=us-ascii
On 28 May 2016, at 19:05, Ken Burgett via swift-users
wrote:
print(buf)
The trick here is to replace the above line with:
print(String(validatingUTF8: buf))
`fgets` sets up `buf` to hold a C string, s
le text file I/O with Swift 3
Message-ID:
Content-Type: text/plain; charset=us-ascii
On 28 May 2016, at 19:05, Ken Burgett via swift-users
wrote:
print(buf)
The trick here is to replace the above line with:
print(String(validatingUTF8: buf))
`fgets` sets up `buf` to hold a C string, s
I am looking for a parser for JSON is compatible with Swift 3 on Linux.
SwiftyJSON looks interesting, but it is Swift 2.2 compatible, AFAIK.
Any URL will be appreciated, and a Swift3 package would bring joy.
--
Ken Burgett
Principal Software Engineer
Email: k...@iotone.io
Office: 530.693.4449
I am converting a very dirty C program to Swift3, and their is plenty of
pointer arithmetic to be dealt with. As part of the effort, I have
created a 'memcpy clone to help with some of the transformation.
Here is the output from the REPL:
1. var source = [UInt
On 2016-06-09 21:37, Joe Groff wrote:
On Jun 9, 2016, at 8:39 PM, Saagar Jha via swift-users
wrote:
Nevermind, I lied. Swift does allow direct pointer arithmetic:
import Foundation
var source = [UInt8](repeating: 0x1f, count: 32)
var destination = [UInt8](repeating: 0, count: 64)
memcpy(&de
15 matches
Mail list logo