What prevents ImportC from using .h directly?
    Chris Piker 
    chris at hoopjump.com
       
    Sun May 12 21:34:30 UTC 2024
    
    
  
Hi D
Import D is working quite well so far.  One limitation is that 
module definitions require a tiny *.c file which is often just:
```C
#include <libheader.h>
```
Creating this file is trivial and has almost no knock-on effects, 
except when dealing with single file programs. I have quite a few 
small utilities with dub headers. It would be handy if I could 
set an import path and use ImportC on the header file directly, 
skipping the small C file all together.  A specific example in my 
case follows.
Given a C-lib interface defined in the header file:
```
/usr/include/cspice/SpiceUsr.h
```
it would be neat if a dub header similar to the following worked:
```d
#!/usr/bin/env dub
/+ dub.sdl:
    name "some_app"
    cImportPaths "/usr/local/include/cspice"
+/
import SpiceUsr;
// ... source continues
```
So, why does ImportC need *.c files exclusively?  I'm sure it 
solves a problem, but I don't know what that problem is.
    
    
More information about the Digitalmars-d-learn
mailing list