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
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.
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.
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
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