Cannot compile C file using ImportC

Stefan Koch uplink.coder at googlemail.com
Tue Nov 9 19:34:44 UTC 2021


On Tuesday, 9 November 2021 at 11:45:28 UTC, rempas wrote:
>
> ```
> toml.c(39): Error: cannot implicitly convert expression 
> `malloc` of type `extern (C) void*(ulong __size)` to `extern 
> (C) void* function(ulong)`
> toml.c(40): Error: cannot implicitly convert expression `free` 
> of type `extern (C) void(void* __ptr)` to `extern (C) void 
> function(void*)`
> ```

What's happening here is that dmd seems to see `free` as function 
rather than a pointer to a function.
changing `static void* (*ppmalloc)(size_t) = malloc;`
to `static void* (*ppmalloc)(size_t) = &malloc;`

may solve your issue.


More information about the Digitalmars-d-learn mailing list