How can I express the type of a function in D?
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Jan 30 20:12:47 UTC 2019
On Wed, Jan 30, 2019 at 07:51:17PM +0000, Neia Neutuladh via Digitalmars-d-learn wrote:
> On Wed, 30 Jan 2019 10:39:21 -0800, Ali Çehreli wrote:
> > import core.demangle;
> >
> > extern(C) int add(int, int);
> >
> > void main() {
> > alias F = typeof(add);
> > pragma(msg, mangle!F("add"));
> > pragma(msg, add.mangleof);
> > }
> >
> > Output:
> >
> > _D3addUiiZi
> > add <-- Is that correct?
>
> `add.mangleof` is correct. In fact, it's definitively correct.
>
> typeof(add) is extern(C) int function(int, int). Based on this output,
> core.demangle seems like it's not taking the extern(C) portion into
> account.
That would be a bug in core.demangle.
T
--
"I suspect the best way to deal with procrastination is to put off the procrastination itself until later. I've been meaning to try this, but haven't gotten around to it yet. " -- swr
More information about the Digitalmars-d-learn
mailing list