Continued: Declarations of the same C struct conflict when imported

György Andrasek jurily at
Thu Sep 5 23:19:55 UTC 2019


I accidentally ran dstep twice and ended up with the following 


ldc 1.17.0, Android/Termux.

libarchive comes in two public header files: `archive.h` and 

Both headers declare `struct archive;` and `struct 
archive_entry;`, faithfully
reproduced by dstep. Trying to import both yields a conflict 

[  6%] Building D object 
/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)

Annoying, but alias can deal with it. The problem comes in 
actually using them. Annotated for clarity:

int archive_read_next_header(archive_h.archive*, 


(I'm guessing this is the correct place to report this since this 
is a notable improvement from ldc 1.13, which didn't even 
understand pointer-to-opaque.)


They told me to go away. :)

I'm not trying to redesign the language, it simply didn't occur 
to me that this won't work or isn't a trivial oversight. (Android 
is dark and full of terrors.)

I can't imagine how it makes the language better to disallow 
cross-module C calls like this, given that the least ugly 
workaround is `void *`.

P.S. @kinke went through the trouble of upgrading ldc on Termux 
while I was busy installing cargo. Android is now ahead of 
Ubuntu. Please give him a medal or something.

More information about the Digitalmars-d mailing list