digitalmars.D - ImportC const
- Steven Schveighoffer (17/17) Jul 09 2022 Brian Callahan has a blog post about ImportC:
- Dave P. (6/23) Jul 09 2022 I reported this as a bug a while ago:
- Max Samukha (3/6) Jul 09 2022 If importing C fails, ImportC is useless, obviously.
- Walter Bright (2/3) Jul 10 2022 So true. I shall have myself flogged forthwith.
- Max Samukha (2/5) Jul 11 2022 Please stream it live!
- surlymoor (2/8) Jul 11 2022 Beerconf is getting out of control.
- Timon Gehr (6/30) Jul 10 2022 It's a "limitation":
Brian Callahan has a blog post about ImportC: https://briancallahan.net/blog/20220704.html One part identifies a current design choice that breaks C code: OK, so I built this file with clang and kept going. There was one more file that DMD couldn't compile: ``` dmd -g -O -P=-DEMACS -P=-DVI -ofexpr.o -c expr.c expr.c(204): Error: cannot modify `const` expression `(*es).tok` expr.c(205): Error: cannot modify `const` expression `(*es).val` ``` I wonder if this is a bug in ImportC. No other C compiler we've tried fails on this code. The answer is, no it's not a bug, it's by design: https://dlang.org/spec/importc.html#const Is there any benefit to breaking any usage of const in C when trying to compile C code? -Steve
Jul 09 2022
On Saturday, 9 July 2022 at 17:07:16 UTC, Steven Schveighoffer wrote:Brian Callahan has a blog post about ImportC: https://briancallahan.net/blog/20220704.html One part identifies a current design choice that breaks C code: OK, so I built this file with clang and kept going. There was one more file that DMD couldn't compile: ``` dmd -g -O -P=-DEMACS -P=-DVI -ofexpr.o -c expr.c expr.c(204): Error: cannot modify `const` expression `(*es).tok` expr.c(205): Error: cannot modify `const` expression `(*es).val` ``` I wonder if this is a bug in ImportC. No other C compiler we've tried fails on this code. The answer is, no it's not a bug, it's by design: https://dlang.org/spec/importc.html#const Is there any benefit to breaking any usage of const in C when trying to compile C code? -SteveI reported this as a bug a while ago: https://issues.dlang.org/show_bug.cgi?id=22759 IMO we should ignore const in this case as presumably the code has already compiled with a different C compiler.
Jul 09 2022
On Saturday, 9 July 2022 at 17:07:16 UTC, Steven Schveighoffer wrote:Is there any benefit to breaking any usage of const in C when trying to compile C code? -SteveIf importing C fails, ImportC is useless, obviously.
Jul 09 2022
On 7/9/2022 10:16 AM, Max Samukha wrote:If importing C fails, ImportC is useless, obviously.So true. I shall have myself flogged forthwith.
Jul 10 2022
On Monday, 11 July 2022 at 04:27:29 UTC, Walter Bright wrote:On 7/9/2022 10:16 AM, Max Samukha wrote:Please stream it live!If importing C fails, ImportC is useless, obviously.So true. I shall have myself flogged forthwith.
Jul 11 2022
On Monday, 11 July 2022 at 07:09:50 UTC, Max Samukha wrote:On Monday, 11 July 2022 at 04:27:29 UTC, Walter Bright wrote:Beerconf is getting out of control.On 7/9/2022 10:16 AM, Max Samukha wrote:Please stream it live!If importing C fails, ImportC is useless, obviously.So true. I shall have myself flogged forthwith.
Jul 11 2022
On 7/9/22 19:07, Steven Schveighoffer wrote:Brian Callahan has a blog post about ImportC: https://briancallahan.net/blog/20220704.html One part identifies a current design choice that breaks C code: OK, so I built this file with clang and kept going. There was one more file that DMD couldn't compile: ``` dmd -g -O -P=-DEMACS -P=-DVI -ofexpr.o -c expr.c expr.c(204): Error: cannot modify `const` expression `(*es).tok` expr.c(205): Error: cannot modify `const` expression `(*es).val` ``` I wonder if this is a bug in ImportC. No other C compiler we've tried fails on this code. The answer is, no it's not a bug, it's by design: https://dlang.org/spec/importc.html#const Is there any benefit to breaking any usage of const in C when trying to compile C code? -SteveIt's a "limitation": https://dlang.org/spec/importc.html#limitations I guess the underlying issue is that type qualifiers and their combinations are implemented as bitfields in DMD, so adding new ones is pretty hard.
Jul 10 2022