Can we use "ImportC" used yet?

data pulverizer data.pulverizer at gmail.com
Sun Oct 17 10:46:30 UTC 2021


Okay wow, this is amazing, I can now call R's standalone math 
library `Rmath.h` by converting:

```
//r2d_con.c
#define __restrict restrict
#define __asm__ asm
#define __extension__
#define __inline
#define __builtin_bswap16
#define __builtin_bswap32
#define __builtin_bswap64

#define MATHLIB_STANDALONE 1
typedef struct _Float128 {unsigned long long x[2];} _Float128;
#include "Rmath.h"
#include "R_ext/Random.h"
```

```
//callr
import r2d;
import std.random: unpredictableSeed;
import std.stdio: writeln;

void main()
{
   set_seed(unpredictableSeed(), unpredictableSeed());
   writeln("rgamma (2, 3): ", rgamma(2, 3));
}

```

Using:

```
gcc -E -P -I"/usr/share/R/include" -lRmath r2d_con.c > r2d.c
dmd callr.d -L-lRmath -L-lm && ./callr
```

Okay it's only the standalone library which is a small part of R, 
but this rocks. The PAHWAHR! Lol.


More information about the Digitalmars-d-learn mailing list