A have a structure like this (defined in bson.h of mongodb c driver):
typedef struct
{
uint32_t domain;
uint32_t code;
char message[504];
} bson_error_t;
In Swift I have a pointer to this structure like this:
err: UnsafePointer<bson_error_t> = ...
Now whatever I do I cannot convert message[504]
(which Swift sees as a tuple of (Int8, Int8, Int8, ...504 times)) to char*
to use it in String.fromCString().
Is it even possible to do that in Swift? As a temporary solution I created a helper C function in a separate .c
file which takes err *bson_error_t
and returns char*
, but this is weird if
Swift cannot do it by itself.