What on earth is std.windows.d?

Sean Kelly sean at f4.ca
Sat Mar 4 14:50:56 PST 2006


Don Clugston wrote:
> jcc7 wrote:
>>>> Don Clugston wrote:
>>> I've been inspired to have a go at making a C2D header converter. I 
>>> know that's been done before, but this one's in D.
> 
>> Please keep us updated on this. I think the D community is really 
>> hungry for a
>> C2D program written in D. I know I'd like to have such a tool in my 
>> toolbelt.
> 
> I think this is crucial. We can't possibly maintain D bindings for all 
> the zillions of C libraries out there, if it's being done manually.
> 
>> (I'm sure some things will always need to be converted manually, but 
>> whatever
>> can be converted automatically lets the humans save their time for more
>> interesting pursuits.)
> 
> I think a 100% automatic conversion is practically impossible, basically 
> because #define is such an ambiguous language construct. eg is
> #define FOO 1
> defining a constant int? Or is it a flag for a later #ifdef in this 
> file? Or in another file?

The most reliable automatic conversion would probably be to feed 
everything through a C preprocessor and do macro replacement but for #if 
(which would be converted to static if).  The downside would be numeric 
literals littered throughout the headers instead of potentially invalid 
auto declarations.  I suppose there's no perfect solution :-/

> My idea is to have a tool that takes a header file and a very short 
> "hints" file, specific to that SDK, which, in an organised format, lists 
> *all* the "manual" changes that need to be made, so that they can be 
> done automatically.
> Provided the header file doesn't change radically between releases, it 
> should be possible to use the same hints file to keep D headers up to 
> date with C ones, without any extra work.

This sounds like a good idea.  And really, it's not common for headers 
to change much between releases anyway.


Sean



More information about the Digitalmars-d mailing list