C compatibility

Nick Sabalausky a at a.a
Wed Jul 15 13:03:13 PDT 2009


"BCS" <none at anon.com> wrote in message 
news:a6268ff81df8cbd3406e78dc0e at news.digitalmars.com...
> Hello grauzone,
>
>> - Normal code you can simply compile in C and link to D. This works
>> perfectly fine. There's no real reason to port it to D. And who ports
>> large portions of code from C to D anyway?
>
> Linking C code can get a bit cludgy when you actually go to use it because 
> of type system miss matches (e.g. C's char* vs. D's char[]). Also cross 
> language inlining doesn't happen. If it's a small block of code, <~200 
> LOC, I'd consider copying the code and pushing the types thought. If you 
> can count on the correct-or-error bit, this is a lot easier.

Also, if I had some C codebase I was actively maintaining, I'd rather switch 
to D than continue working in C. Yea, I'm that tired of C ;)

But FWIW, I do agree that sometimes certain things that are done for the 
sake of C compatibility seem to be...well, taking things a bit further than 
they really need to be at too high of a cost to regular D code. 





More information about the Digitalmars-d mailing list