Re: Translating C headers to D: How do I compile it?

2020-06-28 Thread Kirill via Digitalmars-d-learn
On Sunday, 28 June 2020 at 05:13:32 UTC, Mike Parker wrote: On Sunday, 28 June 2020 at 04:59:12 UTC, Kirill wrote: something.d: module something; int add(int a, int b); This should be extern(C) int add(int a, int b). The extern(C) tells the D compiler to use the standard C calling convention

Re: Translating C headers to D: How do I compile it?

2020-06-27 Thread mw via Digitalmars-d-learn
On Sunday, 28 June 2020 at 04:59:12 UTC, Kirill wrote: Hello. I am learning how to translate C headers to D. But how do I compile it? I am stuck with this. You can try just to use dpp: https://code.dlang.org/packages/dpp instead of doing the translation manually.

Re: Translating C headers to D: How do I compile it?

2020-06-27 Thread rikki cattermole via Digitalmars-d-learn
On 28/06/2020 4:59 PM, Kirill wrote: module something; extern(C) int add(int a, int b); Compile as static library some.c, add to command line of dmd. Should be this simple more or less, depending on compilers and target involved.

Re: Translating C headers to D: How do I compile it?

2020-06-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 28 June 2020 at 04:59:12 UTC, Kirill wrote: Hello. I am learning how to translate C headers to D. But how do I compile it? I am stuck with this. I have 4 files in the same directory: main.d, something.d, some.h, some.c some.h: //header guards int add(int a, int b); some.c: #inclu

Translating C headers to D: How do I compile it?

2020-06-27 Thread Kirill via Digitalmars-d-learn
Hello. I am learning how to translate C headers to D. But how do I compile it? I am stuck with this. I have 4 files in the same directory: main.d, something.d, some.h, some.c some.h: //header guards int add(int a, int b); some.c: #include "some.h" int add(int a, int b) { return a+b; } somet