Using C header libs with importC

2024-09-18 Thread Imperatorn via Digitalmars-d-learn
https://forum.dlang.org/post/qpmqvhipfyyyehvoe...@forum.dlang.org On Monday, 8 January 2024 at 23:00:02 UTC, Dennis wrote: On Monday, 8 January 2024 at 21:56:10 UTC, Renato wrote: but I tried exactly that! Which gives a seg fault. Looks like there's a bug with the -H switch: https://issues.dl

Re: Using C header libs with importC

2024-01-09 Thread Renato via Digitalmars-d-learn
On Monday, 8 January 2024 at 23:00:02 UTC, Dennis wrote: On Monday, 8 January 2024 at 21:56:10 UTC, Renato wrote: but I tried exactly that! Which gives a seg fault. Looks like there's a bug with the -H switch: https://issues.dlang.org/show_bug.cgi?id=24326 That's the bug that is affecting m

Re: Using C header libs with importC

2024-01-09 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 January 2024 at 21:56:10 UTC, Renato wrote: [snip] Importing .h files from d files isn't supported yet because of a dispute with the lookup priority: https://issues.dlang.org/show_bug.cgi?id=23479 https://issues.dlang.org/show_bug.cgi?id=23547 Ah, too bad. Anyway, I was just pl

Re: Using C header libs with importC

2024-01-08 Thread Dennis via Digitalmars-d-learn
On Monday, 8 January 2024 at 21:56:10 UTC, Renato wrote: but I tried exactly that! Which gives a seg fault. Looks like there's a bug with the -H switch: https://issues.dlang.org/show_bug.cgi?id=24326 But that shouldn't be necessary, you should just be able to import the c file. I also tried

Re: Using C header libs with importC

2024-01-08 Thread Renato via Digitalmars-d-learn
On Monday, 8 January 2024 at 21:04:10 UTC, Dennis wrote: On Monday, 8 January 2024 at 18:53:47 UTC, Renato wrote: Perhaps using an intermediate C file to do this would work, but I wanted to know if D can do it. Yes, your best options are either: - rename the .h to .c and edit it so the `STB_

Re: Using C header libs with importC

2024-01-08 Thread Renato via Digitalmars-d-learn
On Monday, 8 January 2024 at 19:17:06 UTC, Lance Bachmeier wrote: On Monday, 8 January 2024 at 18:53:47 UTC, Renato wrote: Is it possible to use C header-only libs from D? In C, I would need to do this: ```c #define STB_DS_IMPLEMENTATION #include "stb_ds.h" ``` The definition must be done in

Re: Using C header libs with importC

2024-01-08 Thread Lance Bachmeier via Digitalmars-d-learn
On Monday, 8 January 2024 at 18:53:47 UTC, Renato wrote: Is it possible to use C header-only libs from D? In C, I would need to do this: ```c #define STB_DS_IMPLEMENTATION #include "stb_ds.h" ``` The definition must be done in a single C file before including the h file. I tried this in D:

Using C header libs with importC

2024-01-08 Thread Renato via Digitalmars-d-learn
Is it possible to use C header-only libs from D? In C, I would need to do this: ```c #define STB_DS_IMPLEMENTATION #include "stb_ds.h" ``` The definition must be done in a single C file before including the h file. I tried this in D: ```d enum STB_DS_IMPLEMENTATION = 1; import stb_ds; ```