JetForMe
(Rick M)
1
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@latencyzero.com
jrose
(Jordan Rose)
2
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@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@latencyzero.com
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
I don’t know how C API is imported, btus INOUT parameter must be mutable, this is a language artifact.
···
Am 16. Januar 2018 um 22:10:13, Rick Mann via swift-users (swift-users@swift.org) schrieb:
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@latencyzero.com
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
JetForMe
(Rick M)
4
Xcode can't properly parse the C header to show me the Swift signature, but if I try calling it like this:
let p = lgs_notify_params_t(notify: lgs_notify_did_enter_background)
lgs_notify(self.ctx, p)
I get this error:
Cannot convert value of type 'lgs_notify_params_t' to expected argument type 'UnsafePointer<lgs_notify_params_t>!'
···
On Jan 16, 2018, at 13:22 , Jordan Rose <jordan_rose@apple.com> wrote:
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@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@latencyzero.com
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
--
Rick Mann
rmann@latencyzero.com
jrose
(Jordan Rose)
5
Oh no, you're right, I'm sorry. You can only do that with arrays at the moment. We do have a bug for this already.
Jordan
···
On Jan 16, 2018, at 16:37, Roderick Mann <rmann@latencyzero.com> wrote:
Xcode can't properly parse the C header to show me the Swift signature, but if I try calling it like this:
let p = lgs_notify_params_t(notify: lgs_notify_did_enter_background)
lgs_notify(self.ctx, p)
I get this error:
Cannot convert value of type 'lgs_notify_params_t' to expected argument type 'UnsafePointer<lgs_notify_params_t>!'
On Jan 16, 2018, at 13:22 , Jordan Rose <jordan_rose@apple.com> wrote:
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@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@latencyzero.com
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
--
Rick Mann
rmann@latencyzero.com <mailto:rmann@latencyzero.com>
Geordie_J
(ephemer)
6
Oh no, you're right, I'm sorry. You can only do that with arrays at the
moment. We do have a bug for this already.
Jordan
But couldn’t you call it like this:
lgs_notify_params_t(notify: [lgs_notify_did_enter_background])
For exactly that reason?
- Geordie
···
Jordan Rose via swift-users <swift-users@swift.org> schrieb am Mi. 17. Jan. 2018 um 01:38:
On Jan 16, 2018, at 16:37, Roderick Mann <rmann@latencyzero.com> wrote:
Xcode can't properly parse the C header to show me the Swift signature,
but if I try calling it like this:
let p = lgs_notify_params_t(notify: lgs_notify_did_enter_background)
lgs_notify(self.ctx, p)
I get this error:
Cannot convert value of type 'lgs_notify_params_t' to expected argument
type 'UnsafePointer<lgs_notify_params_t>!'
On Jan 16, 2018, at 13:22 , Jordan Rose <jordan_rose@apple.com> wrote:
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@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@latencyzero.com
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users
--
Rick Mann
rmann@latencyzero.com
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users