Proof of concept: automatically import C header files

Walter Bright newshound2 at digitalmars.com
Wed Jul 17 12:40:18 PDT 2013


On 7/17/2013 2:27 AM, Jacob Carlborg wrote:
> On 2013-07-17 10:14, Walter Bright wrote:
>
>> Yeah, you do need the full front end. It's pretty amazing how the
>> simplest of .h files seem determined to exercise every last, dark corner
>> of the language.
>>
>> If the converter doesn't accept the full language, you're just going to
>> get a dump truck unloading on it.
>
> When you do have a complete front end you can choose how to handle the language
> constructs the tool cannot (yet) translate. I.e. just skip it, insert a comment
> or similar.

Yes, but the front end itself must be complete. Otherwise,
it's not really practical when you're dealing with things like the preprocessor 
- because a non-compliant front end won't even know it has gone off the rails.

There are other issues when dealing with C .h files:

1. there may be various #define's necessary to compile it that would normally be 
supplied on the command line to the C compiler

2. there are various behavior switches (see the PR for DMD that wants to set the 
signed'ness of char types)

3. rather few .h files seem to be standard compliant C. They always rely on 
various compiler extensions

These problems are not insurmountable, they just are non-trivial and need to be 
handled for a successful .h file importer.


More information about the Digitalmars-d mailing list