Thread overview
[Issue 23357] ImportC: compatible types with definitions leads to redeclaration error when used from D.
Sep 22, 2022
Adam D. Ruppe
Sep 23, 2022
Walter Bright
Oct 03, 2022
Walter Bright
Oct 05, 2022
Dlang Bot
Oct 05, 2022
Dlang Bot
September 22, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

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

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

--- Comment #1 from Adam D. Ruppe <destructionator@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.

--
September 23, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
It's not really necessary to rely on the preprocessor. Just the .i files are fine. The .h files and #include's are irrelevant to the problem.

--
October 03, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
Fix: https://github.com/dlang/dmd/pull/14509

and I don't know why it wasn't automatically posted here.

--
October 05, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright updated dlang/dmd pull request #14509 "fix Issue 23357 - ImportC: compatible types with definitions leads to…" fixing this issue:

- fix Issue 23357 - ImportC: compatible types with definitions leads to redeclaration error when used from D

https://github.com/dlang/dmd/pull/14509

--
October 05, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14509 "fix Issue 23357 - ImportC: compatible types with definitions leads to…" was merged into master:

- a09b5a67352f61e369edf6af0dafddcd188b3378 by lucica28:
  fix Issue 23357 - ImportC: compatible types with definitions leads to
redeclaration error when used from D

https://github.com/dlang/dmd/pull/14509

--
October 05, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

dave287091@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=23388

--
October 05, 2022
https://issues.dlang.org/show_bug.cgi?id=23357

dave287091@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=23387

--