digitalmars.D - built in import c header files
- RazvanN (22/27) Apr 22 2021 As suggested by other participants to this thread, using libclang
- 12345swordy (3/11) Apr 22 2021 How in the world did this thread got split?
- Imperatorn (3/11) Apr 22 2021 Whoa, that sounds really interesting, I hope you can make dpp
- russhy (3/32) Apr 22 2021 In that regard, i think Zig people have done an amazing at being
- 12345swordy (5/34) Apr 22 2021 Anyways, I respectfully disagree, d should import c99 standard
- 12345swordy (3/44) Apr 22 2021 c99 standard compliant header files obviously ;p
- jmh530 (6/17) Apr 22 2021 I don't see why it would be a good idea for DMD/GDC to then be
- 12345swordy (4/23) Apr 22 2021 Why do people keep bringing up libclang here? I am not referring
- Max Haughton (3/23) Apr 22 2021 Implementing C? Not the end of the world, but still a big job.
- jmh530 (3/7) Apr 22 2021 You brought up Zig. How do you think Zig parses C? Answer:
- 12345swordy (4/12) Apr 22 2021 I am more concerns with the ends results rather than the means to
- Mike Parker (3/9) Apr 23 2021 But the means is a very important aspect in terms of maintenance
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? -AlexAs 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
Apr 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:How in the world did this thread got split? -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. [...]
Apr 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:Whoa, that sounds really interesting, I hope you can make dpp even better ☀️[...]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. [...]
Apr 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:In that regard, i think Zig people have done an amazing at being able to transparently consume C codeI 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? -AlexAs 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
Apr 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:Anyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d? -AlexI 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? -AlexAs 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
Apr 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:c99 standard compliant header files obviously ;p -Alexhttps://forum.dlang.org/post/txdjmjkhradboqfmozlm forum.dlang.org On Tuesday, 6 October 2020 at 20:59:54 UTC, 12345swordy 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? -AlexI 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? -AlexAs 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
Apr 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: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.[snip] Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you) RazvanNAnyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d? -Alex
Apr 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:Why do people keep bringing up libclang here? I am not referring to libclang nor dpp as it does more than c here. -AlexOn Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote: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.[snip] Bottom line: it is better to improve dpp than to implement a C parser (when libclang already does that for you) RazvanNAnyways, I respectfully disagree, d should import c99 standard with no compiler extensions out of the box. Zig can do it, why not d? -Alex
Apr 22 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:Implementing C? Not the end of the world, but still a big job. Implementing a C preprocessor? Nightmare.On Thursday, 22 April 2021 at 19:35:36 UTC, 12345swordy wrote:Why do people keep bringing up libclang here? I am not referring to libclang nor dpp as it does more than c here. -AlexOn Thursday, 22 April 2021 at 07:34:42 UTC, RazvanN wrote: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.[...]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
Apr 22 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. -AlexYou brought up Zig. How do you think Zig parses C? Answer: libclang.
Apr 22 2021
On Friday, 23 April 2021 at 00:56:57 UTC, jmh530 wrote:On Thursday, 22 April 2021 at 23:10:36 UTC, 12345swordy wrote:I am more concerns with the ends results rather than the means to achieve said results. -Alex[snip] Why do people keep bringing up libclang here? I am not referring to libclang nor dpp as it does more than c here. -AlexYou brought up Zig. How do you think Zig parses C? Answer: libclang.
Apr 22 2021
On Friday, 23 April 2021 at 01:54:25 UTC, 12345swordy wrote:On Friday, 23 April 2021 at 00:56:57 UTC, jmh530 wrote:But the means is a very important aspect in terms of maintenance cost. What you're proposing is a maintenance nightmare.You brought up Zig. How do you think Zig parses C? Answer: libclang.I am more concerns with the ends results rather than the means to achieve said results. -Alex
Apr 23 2021