Jump to page: 1 2
Thread overview
built in import c header files
Apr 22, 2021
RazvanN
Apr 22, 2021
12345swordy
Apr 22, 2021
Imperatorn
Apr 22, 2021
russhy
Apr 22, 2021
12345swordy
Apr 22, 2021
12345swordy
Apr 22, 2021
jmh530
Apr 22, 2021
12345swordy
Apr 23, 2021
Max Haughton
Apr 23, 2021
jmh530
Apr 23, 2021
12345swordy
Apr 23, 2021
Mike Parker
April 22, 2021
https://forum.dlang.org/post/txdjmjkhradboqfmozlm@forum.dlang.org

On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy wrote:
> I remember reading a reddit comment saying that if d were to import c header files directly without any 3rd party libraries it would be a game changer. The question is: how difficult to implement a C AST parser for the dmd front end?
>
>
> -Alex

As suggested by other participants to this thread, using libclang is the way to go. There really isn't any benefit in having a builtin C parser in dmd. Instead of working on this, I suggest to try to improve dpp as it is easy to install and use.

At UPB we have integrated a D driver in the linux kernel. Initially, we could not use dpp due to the complexity and oddity of the C code used in the kernel, so we translated the header files by hand: it was a nightmare. As Atila pointed out, there was an endless stream of dependencies. After the project was finished, we took on the responsibility to try to make dpp work with the linux kernel. We fixed tens of corner case and it looked like dpp could handle all of the cases, however we then stumbled upon a memory issue due to some bug in std.appender (used internally by dpp). Unfortunately, the student working on fixing dpp abandoned the project at that point, but we are very close to making dpp work with the linux kernel. If that works, I assure you that dpp will work in 99% of the cases.

Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you)

RazvanN
April 22, 2021

On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:

>

https://forum.dlang.org/post/txdjmjkhradboqfmozlm@forum.dlang.org

On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy wrote:

>

[...]

As suggested by other participants to this thread, using libclang is the way to go. There really isn't any benefit in having a builtin C parser in dmd. Instead of working on this, I suggest to try to improve dpp as it is easy to install and use.

[...]

How in the world did this thread got split?

-Alex

April 22, 2021
On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:
> https://forum.dlang.org/post/txdjmjkhradboqfmozlm@forum.dlang.org
>
> On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy wrote:
>> [...]
>
> As suggested by other participants to this thread, using libclang is the way to go. There really isn't any benefit in having a builtin C parser in dmd. Instead of working on this, I suggest to try to improve dpp as it is easy to install and use.
>
> [...]

Whoa, that sounds really interesting, I hope you can make dpp even better ☀️
April 22, 2021
On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:
> https://forum.dlang.org/post/txdjmjkhradboqfmozlm@forum.dlang.org
>
> On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy wrote:
>> I remember reading a reddit comment saying that if d were to import c header files directly without any 3rd party libraries it would be a game changer. The question is: how difficult to implement a C AST parser for the dmd front end?
>>
>>
>> -Alex
>
> As suggested by other participants to this thread, using libclang is the way to go. There really isn't any benefit in having a builtin C parser in dmd. Instead of working on this, I suggest to try to improve dpp as it is easy to install and use.
>
> At UPB we have integrated a D driver in the linux kernel. Initially, we could not use dpp due to the complexity and oddity of the C code used in the kernel, so we translated the header files by hand: it was a nightmare. As Atila pointed out, there was an endless stream of dependencies. After the project was finished, we took on the responsibility to try to make dpp work with the linux kernel. We fixed tens of corner case and it looked like dpp could handle all of the cases, however we then stumbled upon a memory issue due to some bug in std.appender (used internally by dpp). Unfortunately, the student working on fixing dpp abandoned the project at that point, but we are very close to making dpp work with the linux kernel. If that works, I assure you that dpp will work in 99% of the cases.
>
> Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you)
>
> RazvanN

In that regard, i think Zig people have done an amazing at being able to transparently consume C code


April 22, 2021

On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:

>

https://forum.dlang.org/post/txdjmjkhradboqfmozlm@forum.dlang.org

On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy wrote:

>

I remember reading a reddit comment saying that if d were to import c header files directly without any 3rd party libraries it would be a game changer. The question is: how difficult to implement a C AST parser for the dmd front end?

-Alex

As suggested by other participants to this thread, using libclang is the way to go. There really isn't any benefit in having a builtin C parser in dmd. Instead of working on this, I suggest to try to improve dpp as it is easy to install and use.

At UPB we have integrated a D driver in the linux kernel. Initially, we could not use dpp due to the complexity and oddity of the C code used in the kernel, so we translated the header files by hand: it was a nightmare. As Atila pointed out, there was an endless stream of dependencies. After the project was finished, we took on the responsibility to try to make dpp work with the linux kernel. We fixed tens of corner case and it looked like dpp could handle all of the cases, however we then stumbled upon a memory issue due to some bug in std.appender (used internally by dpp). Unfortunately, the student working on fixing dpp abandoned the project at that point, but we are very close to making dpp work with the linux kernel. If that works, I assure you that dpp will work in 99% of the cases.

Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you)

RazvanN

Anyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d?

-Alex

April 22, 2021

On Thursday, 22 April 2021 at 19:35:36 UTC, 12345swordy wrote:

>

On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:

>

https://forum.dlang.org/post/txdjmjkhradboqfmozlm@forum.dlang.org

On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy wrote:

>

I remember reading a reddit comment saying that if d were to import c header files directly without any 3rd party libraries it would be a game changer. The question is: how difficult to implement a C AST parser for the dmd front end?

-Alex

As suggested by other participants to this thread, using libclang is the way to go. There really isn't any benefit in having a builtin C parser in dmd. Instead of working on this, I suggest to try to improve dpp as it is easy to install and use.

At UPB we have integrated a D driver in the linux kernel. Initially, we could not use dpp due to the complexity and oddity of the C code used in the kernel, so we translated the header files by hand: it was a nightmare. As Atila pointed out, there was an endless stream of dependencies. After the project was finished, we took on the responsibility to try to make dpp work with the linux kernel. We fixed tens of corner case and it looked like dpp could handle all of the cases, however we then stumbled upon a memory issue due to some bug in std.appender (used internally by dpp). Unfortunately, the student working on fixing dpp abandoned the project at that point, but we are very close to making dpp work with the linux kernel. If that works, I assure you that dpp will work in 99% of the cases.

Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you)

RazvanN

Anyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d?

-Alex

c99 standard compliant header files obviously ;p

-Alex

April 22, 2021

On Thursday, 22 April 2021 at 19:35:36 UTC, 12345swordy wrote:

>

On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:

>

[snip]

Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you)

RazvanN

Anyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d?

-Alex

I don't see why it would be a good idea for DMD/GDC to then be dependent on libclang. Zig only has one compiler back end (LLVM) to worry about.

A dpp that works for 99% of C code is a pretty great thing. It will only get better as more people use it.

April 22, 2021

On Thursday, 22 April 2021 at 20:12:07 UTC, jmh530 wrote:

>

On Thursday, 22 April 2021 at 19:35:36 UTC, 12345swordy wrote:

>

On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:

>

[snip]

Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you)

RazvanN

Anyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d?

-Alex

I don't see why it would be a good idea for DMD/GDC to then be dependent on libclang. Zig only has one compiler back end (LLVM) to worry about.

A dpp that works for 99% of C code is a pretty great thing. It will only get better as more people use it.

Why do people keep bringing up libclang here? I am not referring to libclang nor dpp as it does more than c here.
-Alex

April 23, 2021

On Thursday, 22 April 2021 at 23:10:36 UTC, 12345swordy wrote:

>

On Thursday, 22 April 2021 at 20:12:07 UTC, jmh530 wrote:

>

On Thursday, 22 April 2021 at 19:35:36 UTC, 12345swordy wrote:

>

On Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote:

>

[...]

Anyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d?

-Alex

I don't see why it would be a good idea for DMD/GDC to then be dependent on libclang. Zig only has one compiler back end (LLVM) to worry about.

A dpp that works for 99% of C code is a pretty great thing. It will only get better as more people use it.

Why do people keep bringing up libclang here? I am not referring to libclang nor dpp as it does more than c here.
-Alex

Implementing C? Not the end of the world, but still a big job.

Implementing a C preprocessor? Nightmare.

April 23, 2021

On Thursday, 22 April 2021 at 23:10:36 UTC, 12345swordy wrote:

>

[snip]

Why do people keep bringing up libclang here? I am not referring to libclang nor dpp as it does more than c here.
-Alex

You brought up Zig. How do you think Zig parses C? Answer: libclang.

« First   ‹ Prev
1 2