www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to set linkage?

In the DMD compiler frontend, the type `TypeFunction` (cf. 
astbase.d) representing a function type has a `linkage` member. 
Setting this member when parsing seems to have no effect. How do 
I set the linkage of a function type?

For alias declarations which support setting function type 
linkage, in parse.d, it creates a `LinkageDeclaration`, which I 
cannot do because my function type is not declared, but 
(potentially) nested in something else.

My overall goal is to allow linkage as part of a function pointer 
/ delegate type:
```
void f(extern(C) void function() cFunctionPtr) { }
alias CFP = extern(C) void function();
void g(CFP cFunctionPtr) { }
```

I can already parse this, but `pragma(msg, typeof(&f), '\n', 
typeof(&g))` gives me:
```
void function(void function() cFunctionPtr)
void function((extern (C) void function()) cFunctionPtr)
```
This shows that the linkage of `f`’s parameter is not seen 
somehow, but when the linkage is seen, it properly does end up in 
the parameter’s type.
Dec 20 2023