type in extern declaration

Tejas notrealemail at gmail.com
Tue Sep 21 05:40:18 UTC 2021


On Monday, 20 September 2021 at 20:02:24 UTC, NonNull wrote:
> How do I write the type of a function so as to alias it, and 
> use that in an extern(C) declaration?
>
> For example, how do I write the type of an external function
>
> int main2(int argc, char** argv) {
>     //
> }
>
> ?
>
> This is not
>
> int function(int, char**)
>
> because this is the type of a function pointer of the right 
> type, not the type of the function itself.
>
> If I had that type aliased to mainfunc I could write
>
> extern(C) mainfunc main2;
>
> in D source to arrange to call it, and similarly any other 
> functions of the same type.

This is for C++, but I think you'll find it helpful all the same

https://atilaoncode.blog/2019/03/07/the-joys-of-translating-cs-stdfunction-to-d/



More information about the Digitalmars-d-learn mailing list