[swift-users] Cannot pass immutable value as inout argument

Jordan Rose jordan_rose at apple.com
Tue Jan 16 15:22:34 CST 2018


You can do this if you don't write '&', which incorporates the caveat that you're not passing a stable address. But please file a bug anyway, because the diagnostic should tell you that!

Jordan


> On Jan 16, 2018, at 13:10, Rick Mann via swift-users <swift-users at swift.org> wrote:
> 
> Is it not possible for Swift to treat C API const pointers as something that can take let arguments?
> 
> 
> LGS_EXPORT bool lgs_notify(struct lgs_context_t* ctx, const lgs_notify_params_t* params);
> .
> .
> .
> let p = lgs_notify_params_t(...)
> lgs_notify(self.ctx, &p)
>                     ^Cannot pass immutable value as inout argument: 'p' is a 'let' constant
> 
> 
> Why isn't the "const" in the C declaration enough to let Swift know it's const and just allow it to be a let?
> 
> -- 
> Rick Mann
> rmann at latencyzero.com
> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20180116/4779693d/attachment.html>


More information about the swift-users mailing list