I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html
How to use ImportC?
Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
March 03, 2022 How to use ImportC? | ||||
---|---|---|---|---|
| ||||
March 03, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leonardo | On Thursday, 3 March 2022 at 19:05:22 UTC, Leonardo wrote:
> I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html
> How to use ImportC?
I think you nailed it... with "incomplete".
|
March 04, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leonardo | On Thursday, 3 March 2022 at 19:05:22 UTC, Leonardo wrote: >I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html You just add the C files like D files when you compile and import them in your D code as you would a D module. At least that is all I've been doing. Simple example: foo.c:
program.d:
Compilation:
|
March 04, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bachmeier | Thanks but not worked here.
|
March 04, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leonardo | On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: >Thanks but not worked here.
They must have introduced a bug. Works for me with DMD 2.098.0 and LDC 1.28.0. ImportC is under heavy development right now. Most of the 2.098.1 changelog was related to ImportC. |
March 04, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leonardo | On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: >Thanks but not worked here.
Please retry with the beta or nightly build. I think your bug was already fixed since 2.098.1. |
March 04, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to MoonlightSentinel | On Friday, 4 March 2022 at 17:17:17 UTC, MoonlightSentinel wrote: >On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: >Thanks but not worked here.
Please retry with the beta or nightly build. I think your bug was already fixed since 2.098.1. Just had a chance to try this. Works with the beta. |
March 07, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leonardo | On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: >Thanks but not worked here.
... >/usr/include/dlang/dmd/core/stdc/stdio.d(1485): Error: function
LDC works with DMD fronted the same version v2.098.1 LDC - the LLVM D compiler (1.28.1): |
March 18, 2022 Re: How to use ImportC? | ||||
---|---|---|---|---|
| ||||
Posted in reply to MoonlightSentinel | On Friday, 4 March 2022 at 17:17:17 UTC, MoonlightSentinel wrote: >On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: >Thanks but not worked here.
Please retry with the beta or nightly build. I think your bug was already fixed since 2.098.1. Thank you all. In v2.099.0 it works. |