I'm importing a C header in Swift using a bridging header. My C API looks something like this:
typedef struct MyStruct {
char buff[80];
} MyStruct;
const char* GetBuff(const MyStruct* m);
Now in Swift I try to call it like this:
let b = MyStruct()
let mystr = String(cString: GetBuff(&b))
Then I get this compile error: "Cannot pass immutable value as inout argument: 'b' is a 'let' constant". Why is this? The argument to GetBuff() is a const pointer. Isn't a const pointer immutable?
I know that changing 'b' to 'var b' will fix the problem but why is it necessary?