[Issue 23926] New: ImportC: D can’t pass pointer to const struct to C function declared taking pointer to const struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 18 16:39:39 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23926
Issue ID: 23926
Summary: ImportC: D can’t pass pointer to const struct to C
function declared taking pointer to const struct
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
// foo.c
struct Foo;
void foo(const struct Foo* x);
// usefoo.d
import foo;
void bar(const Foo* x){
//Error: function `foo.foo(Foo* x)` is not callable using argument types
`(const(Foo*))`
// cannot pass argument `x` of type `const(Foo)*` to parameter `Foo*
x`
foo.foo(x);
}
I believe const was stripped so that C function bodies could be compiled, but
it should be preserved for the purpose of calling from D.
--
More information about the Digitalmars-d-bugs
mailing list