htod - convert C .h files to D import files
Walter Bright
newshound at digitalmars.com
Tue May 23 10:50:19 PDT 2006
Don Clugston wrote:
> A perfect H to D converter is probably impossible, because #defines are
> so ambiguous.
Not just that, there are things like using "char" as "byte" in C code.
There's no way to reliably distinguish the usages.
> It takes a human who knows how the header file is intended
> to be used.
That's right. That's why the original declarations are included as
comments to make it easy to go through the results line by line and
check them.
> However, it ought to be possible to construct patch files to
> apply to C headers prior to running them into htod. It also seems
> feasible in the long term to persuade some open-source projects to make
> their headers D-friendly.
That's why the __HTOD__ macro is predefined when running htod.
> I'm left wondering what this means for the Windows API project. I
> certainly would have done things differently, if I'd known this was
> coming. Where to now?
Windows would still need a lot of hand work because of its heavy
dependence on the preprocessor. There are still nearly 100,000 lines of
code to check.
What I hope is that the D outputting version of SWIG will no longer be
necessary, that one can just run the C output of SWIG through htod. That
way we can easily leverage all the work put into SWIG by others.
More information about the Digitalmars-d-announce
mailing list