importC - how to use more effectively?

WebFreak001 d.forum at webfreak.org
Wed Feb 22 15:00:56 UTC 2023


I just first time used importC in a prototype project I just 
worked on. I used it to just import `libevdev.h` on linux to 
register a custom input device / make a simple userspace input 
driver.

Now libevdev comes with two header files: libevdev.h and 
libevdev-uinput.h

Q1) Since libevdev-uinput.h included libevdev.h, I could simply 
import that to get everything. What would I do in more complex 
libraries that are composed of multiple header files though?

I had a small problem: linux/input.h was included, but not found 
/ not properly processed, so I had to manually look that up in 
the correct architecture folder of my linux distro.

What I now did was copy-pasting the files both from libevdev and 
from linux/input.h from my local system into my project 
directory, running `gcc -E` and manually cleaning up things, so 
that stuff like `u8` existed. (using a package in D that I would 
`__import` to include compat things)

Q2) How would I do this without manually copying and editing the 
header files, so that it would work on other people's machines as 
well, using their local headers?

---

I'm quite a fan of how easy it was using importC to get libevdev 
running in my custom program and quickly making a basic custom 
input device, exactly with the same syntax and functions as in C, 
but this only really seems to work inside the prototyping phase. 
What would be the next steps if I wanted to make e.g. a libevdev 
wrapper to put on DUB?

Q3) Would generating D code from importC be possible for this?


More information about the Digitalmars-d-learn mailing list