cast to pure function stop work after upgrade
vit
vit at vit.vit
Mon Aug 2 15:10:06 UTC 2021
On Monday, 2 August 2021 at 11:28:46 UTC, Tejas wrote:
> On Monday, 14 June 2021 at 13:31:51 UTC, baby_tiger wrote:
>> [...]
>
>
> It seems to not work at runtime either. Maybe they've made this
> behaviour illegal now? Hopefully someone answers.
>
> ```d
>
> import std.traits;
> import core.stdc.stdarg;
> enum LogLevel : ubyte {
> INFO = 0,
> WARN,
> ERROR,
> FATAL,
> }
>
>
> extern (C) string VFORMAT(LogLevel level, string file, size_t
> line, char[] tmp, bool line_break, string tag, string fmt, ...)
> @nogc nothrow {
> return null;
> }
>
> extern (C) string function(LogLevel level, string file, size_t
> line, char[] tmp, bool line_break, string tag, string fmt, ...)
> @nogc nothrow pure fp;
> void main(){
> fp = &VFORMAT; //fails
> }
> ```
Try this:
```d
void main(){
fp = cast(typeof(fp))&VFORMAT; //fails
}
```
More information about the Digitalmars-d-learn
mailing list