ImportC Rox
confuzzled
con at fuzzled.com
Thu Nov 10 16:25:34 UTC 2022
On Monday, 7 November 2022 at 22:05:38 UTC, Walter Bright wrote:
> https://news.ycombinator.com/item?id=33509223
So I read the responses to this post along with the [ImportC
documentation](https://dlang.org/spec/importc.html) and was
excited to try this out. I first copied hello.c from the docs and
attempted to compile it with dmd. The result:
```
dmd hello.c
hello.c(1): Error: C preprocessor directive `#include` is not
supported
hello.c(1): Error: no type for declarator before `#`
hello.c(5): Error: no type for declarator before `return`
hello.c(6): Error: no type for declarator before `}`
```
Hmm... that didn't work. No idea how to fix that either. Let me
try the next example. Output:
```
dmd demo.d square.c
demo.d(6): Error: function expected before `()`, not `module
square` of type `void`
```
That didn't work either. But if I replace the call to square() on
line 6 with square.square(), it works fine.
Now, let's try an actual library. First clone xlsxio from github
and run ```cd xlsxio; make install```. Next create demo.d:
```d
import xlsxio_read;
void main()
{
}
```
and compile it (I copied the header file into the root project
directory):
```d
dmd demo.d xlsxio_read.h libxlsxio_read.a
Error: unrecognized file extension h
```
Hmmm... What am I missing?
Thanks,
confuzzled!!!
More information about the Digitalmars-d
mailing list