Comment

Comment by WalterBright

> You can’t actually write a C parser

Actually, you can. I added one to the D compiler, and dubbed it ImportC. With ImportC, in your D code you can write:

    import stdio;
and if there's a stdio.h file, the D compiler will read the .h file, parse it, and present the ABI to it in a D-ish manner to your D code. Here it is:

https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cp...

It's so darned useful I expect other languages will do it, too. People were skeptical at first, but it's a solid gold productivity enhancer.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton