How to do a function pointer to "malloc" and "free"?

rempas rempas at tutanota.com
Sun Oct 10 13:56:06 UTC 2021


On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote:
>
> Hopefully it will :-) .
>
> D has some good C support. You can call any C function from `D` 
> by declaring it `extern(C) <function-signature>`.
>
> The language subset "BetterC" is required for calling D 
> functions from C though. Unfortunately, the runtime features of 
> BetterC are limited and some of C's language features aren't 
> availabe like C99 variable-length-arrays. "BetterC" is like 
> programming in C with little more comfort but phobos is 
> unusable which makes BetterC almost no improvement over C. 
> BetterC helper librarys like Tanya or Tango do exist.
>
> In that case it can indeed be better for you to convert the 
> program's entry point into D code. This is unfortunate because 
> it prevents C code bases from using D.
>
> There is a tool [C++ Conversion 
> Wizard](https://rainers.github.io/visuald/visuald/CppConversion.html) which could be able to convert C++ and C to D but I don't know how good it is and whether it's usable for free on a GNU/Linux derivative OS. It's only half-automatic.

Actually I know about BetterC and how to call C functions from D 
and visa versa. I would also disagree that "BetterC" is almost no 
improvement over C as about 90% of the language is there!! C++ 
classes are also supported


More information about the Digitalmars-d-learn mailing list