Add ImportC compiler to dmd
12345swordy
alexanderheistermann at gmail.com
Tue May 11 18:37:22 UTC 2021
On Tuesday, 11 May 2021 at 16:57:15 UTC, IGotD- wrote:
> On Sunday, 9 May 2021 at 20:57:06 UTC, Walter Bright wrote:
>> https://github.com/dlang/dmd/pull/12507
>>
>> If you could add a C compiler to dmd with 3000 lines of code,
>> so C code could be imported directly? I would!
>
> I'd say no to this.
>
> Why?
>
> Adding a C compiler into the D compiler will increase the
> maintenance work load and open up for new interesting bugs.
> This is the last D needs. Also there are several areas where D
> needs to improve (memory management) and add this split
> personally is a distraction.
>
> I also find this a bit strange coming from a person that thinks
> making GC pointers an own type would increase the complexity of
> the compiler, then suddenly wants to add a complete C compiler
> into the D compiler.
>
> Also the question raises what will be supported and what will
> not. There are a lot of header files out there that are a mix
> between C and C++. Adding importing C++ is difficult and the
> scope what is supported must be limited. This means that a lot
> of header files will not work directly. C++11 and beyond with
> templates, just forget it.
>
> I understand that importC would greatly make FFI easier but I
> think this is easier said than done. It is definitely not worth
> making the D compiler into a Frankensteins monster. I would go
> the conversion tool (that converts C header files to D files)
> route in order to decouple a foreign language to the D language.
Read the change log, there are no plans for importing C++ files.
C (without the preprocessor nonsense) is a very simple
programming language. There are huge number of C libraries out
there. The ability to simply import them and "Just work" will be
a huge boost to adoption rate when it comes the d language.
-Alex
More information about the Digitalmars-d
mailing list