October 23
On Monday, 23 October 2023 at 00:41:58 UTC, Walter Bright wrote:
> On 10/22/2023 4:45 PM, jmh530 wrote:
>> Sorry but I don’t think I’ve ever used .di files. What is the significance of this?
>
> .di files serve the same purpose as .h files do in C.

Looks like the documentation on them has been improved too since the last time I looked at it:

https://dlang.org/dmd-windows.html#interface-files
October 23
On Monday, 23 October 2023 at 12:43:24 UTC, jmh530 wrote:
> On Monday, 23 October 2023 at 00:41:58 UTC, Walter Bright wrote:
>> On 10/22/2023 4:45 PM, jmh530 wrote:
>>> Sorry but I don’t think I’ve ever used .di files. What is the significance of this?
>>
>> .di files serve the same purpose as .h files do in C.
>
> Looks like the documentation on them has been improved too since the last time I looked at it:
>
> https://dlang.org/dmd-windows.html#interface-files

try on osx: dmd, ldc2, ldmd2.  all get this error:

Error: unrecognized file extension h
October 23
On Monday, 23 October 2023 at 16:08:58 UTC, d007 wrote:

> try on osx: dmd, ldc2, ldmd2.  all get this error:
>
> Error: unrecognized file extension h

What version is your compiler? If it's too old, it won't have that support.
October 23
On 10/23/2023 9:08 AM, d007 wrote:
> Error: unrecognized file extension h

That's because recognizing h files caused Iain problems building gdc.

To deal with:

--- file.c ---
#include "file.h"
--------------
October 25
On Saturday, 21 October 2023 at 02:13:24 UTC, Walter Bright wrote:
> Bruce and Adam and I met at a Red Robin in Seattle to chat about D, and they both made a case for the D compiler being able to translate C files into .di "header" files.

If anybody else is in the area on the third Wednesday of the month we usually meetup at the NWCPP talk and then head out somewhere afterwards to chat. Usually D, sometimes not. If you want more details you can DM me on Discord.

> The idea is to:
>
> 1. be able to work with D IDE programs that can only deal with D code
>
> 2. be able to handle the vast bulk of converting .h to D code, and then tweak by hand the bits that didn't translate well

3. Can be useful for debugging calls to ImportC methods so you can see where you messed up at the call site.

> Anyhow, I pontificated that this couldn't be done, because some C code is not representable as D code. Silly me.
>
> But I got to thinking about it. It turns out that DMD can currently do this:
>
>     dmd -c test.c -Hf=test.di
>
> and voila! It creates a .di file from the C file. Who knew?

This is pretty much how I stumbled on to it at DConf this year. I briefly started with a hand translation of the ODBC 4 headers, got bored, then Nick Wilson suggested I look into ImportC, and then I just decided to smash the -Hf onto the end to see if it would work. The first file I tried it on worked, so I kept going. Eventually I ran into an anonymous tagged enum that D doesn't support, but the trick was to just comment it out and retry.

D simply doesn't support every C semantic, and that's OK, it's not supposed to, so where it doesn't, some better error messages are all we need to make this system more accessible. But it works! One place I can see something like this being popular is building DUB-based Code-D enabled (VSCode and others) bindings for non-source-available C libraries. There is a universe of C libraries waiting for us to generate bindings and bring them to D.

And if you miss DConf, you're really missing out. The interactions are top-shelf, and even if you don't learn anything from the talks (but you will), the discussions you have with the attendees more than make up the price of admission.

> It could use some adjustment, but the bulk is there and it didn't crash or launch nuclear missiles. (Phew!)

Some helpful adjustments (if possible):
- Ability to set an explicit module name for the DI file. (Useful for creating properly namespaced bindings for libraries like ODBC.)
- One module per header file. For example, in the ODBC headers, they all reference a common header for types. If D could follow that on the output side we wouldn't have undo the duplicated types by hand. Don't know if it's possible, but it'd be a serious time saver.

Mix all that together and there are some significant gains to made to the language's  capabilities just by importing C libraries. I love it!

-AW
October 25
On Saturday, 21 October 2023 at 02:13:24 UTC, Walter Bright wrote:
> and voila! It creates a .di file from the C file. Who knew?

I knew. In fact, it only works because I fixed it myself:

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

> It could use some adjustment, but the bulk is there and it didn't crash or launch nuclear missiles. (Phew!)

https://www.youtube.com/watch?v=79DijItQXMM
October 24
On 10/24/2023 5:29 PM, Adam Wilson wrote:
> Eventually I ran into an anonymous tagged enum that D doesn't support, but the trick was to just comment it out and retry.

File it as a bugzilla!
October 24
On 10/24/2023 5:52 PM, Adam D Ruppe wrote:
> I knew. In fact, it only works because I fixed it myself:
> 
> https://github.com/dlang/dmd/pull/15557

Thanks for fixing it.

October 25
On Wednesday, 25 October 2023 at 01:26:43 UTC, Walter Bright wrote:
> On 10/24/2023 5:29 PM, Adam Wilson wrote:
>> Eventually I ran into an anonymous tagged enum that D doesn't support, but the trick was to just comment it out and retry.
>
> File it as a bugzilla!

Way ahead of you. From DConf: https://issues.dlang.org/show_bug.cgi?id=24121
October 24
On 10/24/2023 7:42 PM, Adam Wilson wrote:
> Way ahead of you. From DConf: https://issues.dlang.org/show_bug.cgi?id=24121

Thanks. I think I can take care of it.