Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 18, 2023 [Issue 23926] ImportC: D can’t pass pointer to const struct to C function declared taking pointer to const struct | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23926 dave287091@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ImportC -- |
May 18, 2023 [Issue 23926] ImportC: D can’t pass pointer to const struct to C function declared taking pointer to const struct | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23926 --- Comment #1 from dave287091@gmail.com --- Thinking more about this, C doesn’t have transitive const so maybe this is actually correct. Maybe D needs head const to properly express C const. -- |
May 18, 2023 [Issue 23926] ImportC: D can’t pass pointer to const struct to C function declared taking pointer to const struct | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23926 --- Comment #2 from dave287091@gmail.com --- (In reply to dave287091 from comment #1) > Thinking more about this, C doesn’t have transitive const so maybe this is actually correct. Maybe D needs head const to properly express C const. The error message could be improved though. -- |
May 23, 2023 [Issue 23926] ImportC: D can’t pass pointer to const struct to C function declared taking pointer to const struct | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23926 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution|--- |LATER --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- You're right, it's about the non-transitivity of C const. D's choices are: 1. compile correct C code, and also compile some incorrect C code 2. not compile some correct C code, not compile incorrect C code 3. implement non-transitive const in D (1) is the most pragmatic choice. Maybe eventually we can do (3), but it's a low priority. Note that any hand-translated C code to D has the same issue. Improving the error message also would be rather clumsy. I wish I had better news on that. BTW, `const struct Foo*` in C looks like const(Foo)* in D, while `const Foo*` in D is actually `const(Foo*)`. I'm going to resolve this as "LATER". -- |
February 28 [Issue 23926] ImportC: D can’t pass pointer to const struct to C function declared taking pointer to const struct | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23926 Lance Bachmeier <lance@lancebachmeier.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lance@lancebachmeier.com --- Comment #4 from Lance Bachmeier <lance@lancebachmeier.com> --- Can this be resolved by having ImportC generate a D overload? If const struct Foo* is rewritten to Foo*, it should. This is a solution for this particular example: struct Foo; void foo(Foo* x) {} // ImportC generates this function when encountering const struct Foo* void foo(const(Foo)* x) { foo(cast(Foo*) x); } void bar(const Foo* x) { foo(x); } -- |
Copyright © 1999-2021 by the D Language Foundation