[Issue 23357] ImportC: compatible types with definitions leads to redeclaration error when used from D.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 22 11:41:06 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23357

Adam D. Ruppe <destructionator at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator at gmail.com

--- Comment #1 from Adam D. Ruppe <destructionator at gmail.com> ---
I'd also want to test if 1) functions defined twice work right (i think they do
but would want to confirm) and 2) if structs with the same name but different
layouts do error.

Same name, same layout should work in C. Same name, different layout C will
allow if they are in different translation units, but for D, this gets a little
bit awkward. We don't have the same compilation model (really hacking C into
the import system was and remains a mistake, it just doesn't actually work) so
we'd need to change the rule a bit.

I'd propose that the D rule be if the structs are defined the same, allow the
multiple definition and merge them into the same namespace. If not, then issue
the multiple definition error.

--


More information about the Digitalmars-d-bugs mailing list