for this test case:
test2i.c
typedef struct Message Message;
int tryEncode(const Message* msg);
test2d.d
import test2i;
extern(C) int main(int argc, char** argv){
doTest!test2i();
return 0;
}
void doTest(alias M)(){
static foreach(symbol; __traits(allMembers, M)) if( true ) {
static if( __traits(compiles, typeof(__traits(getMember, M, symbol))) ) {
alias T = typeof(__traits(getMember, M, symbol));
static if( is( T == function) ) {
pragma(msg, symbol, "\t", T);
}
}
}
}
dmd --version
DMD64 D Compiler v2.107.1-rc.1
Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved written by Walter Bright
dmd test2d.d -betterC
tryEncode extern (C) int(Message* msg)
the output should be tryEncode extern (C) int(const(Message)* msg)
=============
there is one more bugs: if I pass T as alias to template, I will loss parameters name. (ParameterIdentifierTuple return empty string)