| |
| Posted by Walter Bright in reply to max haughton | PermalinkReply |
|
Walter Bright
Posted in reply to max haughton
| On 1/29/2024 5:59 PM, max haughton wrote:
> Surely you of all people would know that? I was one of the first people (that I'm aware of at least) to build and play with ImportC (i.e. slightly prior to it being announced) and it immediately blew up (even after preprocessing) on some GNU headers -- the trend wasn't hard to see.
My priority was compiling Standard C, not C extensions. I assumed that the gnu C headers would at least try to stick with Standard C for the Standard C header files. Oops!
To add more complication, the different Posix versions had dramatically different Standard C header files, using different extensions.
>>> What has worked surprisingly well is converting C headers to D and then using traits to create dynamic bindings at compile time. So while it is not what I originally thought it would be, it's been a win for me in a different way.
>>
>> You and Adam Wilson! An unanticipated use, for sure.
>
> So what dstep has been doing for years?
As has htod that I wrote, and dpp that Atila wrote.
> The value of ImportC is in importing c, i.e. thats the thing that the others can't do. Even then I think the lack of tools for doing it on the fly as part of a build with (say) dub does reveal that the demand is not as great as some think. The language is better with it, obviously, but I'm genuinely not sure if the strategic investment has paid off i.e. it's still in large viewed as a toy / solution for yesterday's problem industrially at least (I think we *switched* to using it for some bits and pieces recently it must be said but it didn't enable anything new).
>
> That and the binding generation is probably not as good as what you can do with DStep because it works with a higher level and frankly much more modern AST from a real C compiler i.e. more info to play with, and info that hasn't potentially been through a bunch of D semantic passes - which does mean that you can potentially do ExportD, in fairness.
ImportC is a real C compiler. It doesn't need D to compile, link, and run C programs. It isn't, however, a clone of gcc, clang, or msvc.
The .di code generation happens before semantic analysis, not after.
What info to play with is it missing?
Bottom line - if Dstep works for your purposes, great! Use it!
|