ImportC can now automatically run the preprocessor

Andrea Fontana nospam at example.com
Sun May 15 20:08:32 UTC 2022


On Sunday, 15 May 2022 at 17:45:29 UTC, Walter Bright wrote:
> On 5/15/2022 8:34 AM, Andrea Fontana wrote:
>> I've imported some libraries directly into D. Not the headers, 
>> the whole library.
>
> Shazam! Tell us more!

I tested it  with some small libraries that do not need a 
makefile to compile (I'm too lazy to convert them).

For example this one 
https://github.com/nayuki/QR-Code-generator/tree/master/c works 
fine with the follow glue code:

```
#define __restrict restrict
#define __asm__ asm
#define __extension__
#define __inline inline
#define __signed__
#define _GNU_SOURCE

#include "qrcodegen.h"


static const int qrcode_VERSION_MIN = qrcodegen_VERSION_MIN;
static const int qrcode_VERSION_MAX = qrcodegen_VERSION_MAX;


size_t qrcode_BUFFER_LEN_FOR_VERSION(size_t n) { return 
qrcodegen_BUFFER_LEN_FOR_VERSION(n); }
size_t qrcode_BUFFER_LEN_MAX() { return 
qrcodegen_BUFFER_LEN_FOR_VERSION(qrcodegen_VERSION_MAX); }

#include "qrcodegen.c"
```

I use tcc to preprocess since it output a lot cleaner code.
Anyway I've imported many headers too, like libvlc, ffmpeg and so 
on...

Andrea



More information about the Digitalmars-d mailing list