Continued: Declarations of the same C struct conflict when imported
Jacob Carlborg
doob at me.com
Sat Sep 7 13:41:48 UTC 2019
On 2019-09-06 01:19, György Andrasek wrote:
> Hi,
>
> I accidentally ran dstep twice and ended up with the following interaction:
>
> https://github.com/ldc-developers/ldc/issues/3155
>
> ---
>
> ldc 1.17.0, Android/Termux.
>
> libarchive comes in two public header files: `archive.h` and
> `archive_entry.h`.
>
> Both headers declare `struct archive;` and `struct archive_entry;`,
> faithfully
> reproduced by dstep. Trying to import both yields a conflict immediately:
>
> ```
> [ 6%] Building D object CMakeFiles/wng.dir/src/wngbase/libarchive.o
> /data/data/com.termux/files/home/weidu-ng/src/wngbase/libarchive.d(27):
> Error: `archive_h.archive` at
> /data/data/com.termux/files/home/weidu-ng/src/wngbase/binding/archive_h.d(122)
> conflicts with `archive_entry_h.archive` at
> /data/data/com.termux/files/home/weidu-ng/src/wngbase/binding/archive_entry_h.d(92)
>
> /data/data/com.termux/files/home/weidu-ng/src/wngbase/libarchive.d(28):
> Error: `archive_h.archive_entry` at
> /data/data/com.termux/files/home/weidu-ng/src/wngbase/binding/archive_h.d(123)
> conflicts with `archive_entry_h.archive_entry` at
> /data/data/com.termux/files/home/weidu-ng/src/wngbase/binding/archive_entry_h.d(93)
>
> ```
It's easier if you can show the code. Is one declaration a forward
reference and the other a definition or are both forward references?
It's a known limitation of DStep. DStep would need to look at all files
and if one is a forward reference replace that with an import. If all
declarations are forward references I guess DStep would need to
arbitrary pick one as the "main" one and replace the other ones with
imports and/or aliases. I know this issue has come up before. I might
already have been reported here [1].
[1] https://github.com/jacob-carlborg/dstep/issues
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list