Does someone know how to fix WTF::Function on Windows

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Does someone know how to fix WTF::Function on Windows

Darin Adler
Hi folks.

On Windows, WTF::Function doesn’t quite work right. Code that is something like this:

    void addCallback(WTF::Function<void()>&&);

    void testFunction()
    {
        // ...
    }

    void addTestFunction()
    {
        addCallback(testFunction);
    }

Leads to errors like this:

    error C2664: 'void addCallback(WTF::Function<void (void)> &&)': cannot convert argument 1 from 'void (__cdecl *)(void)' to 'WTF::Function<void (void)> &&'
    note: You cannot bind an lvalue to an rvalue reference

The problem might have something to do with cdecl vs. stdcall functions, but I am not sure that is the problem. It could be some other problem with how WTF::Function is written. Or it might even be a bug in the Visual Studio compiler. Since I don’t have a Windows machine myself, I was trying to use EWS to figure this out but that was slow. Then I tried using http://webcompiler.cloudapp.net but I could not reproduce any error there when I pasted in cut down code; it just compiled fine.

Is there someone who knows how to fix this?

Another way to put this is: We want to take off the explicit WTF::Function conversions in functions like canUseWithReason in SimpleLineLayout.cpp, Page::Page in Page.cpp, and Worker::Worker in Worker.cpp and have it still compile and work on Windows. Other platforms seem to compile fine without the explicit WTF::Function.

— Darin
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does someone know how to fix WTF::Function on Windows

Yusuke SUZUKI
I'm not 100% confident, but can you try it `&testFunction` instead?

Regards,
Yusuke Suzuki

On Sun, Jul 16, 2017 at 1:13 AM, Darin Adler <[hidden email]> wrote:
Hi folks.

On Windows, WTF::Function doesn’t quite work right. Code that is something like this:

    void addCallback(WTF::Function<void()>&&);

    void testFunction()
    {
        // ...
    }

    void addTestFunction()
    {
        addCallback(testFunction);
    }

Leads to errors like this:

    error C2664: 'void addCallback(WTF::Function<void (void)> &&)': cannot convert argument 1 from 'void (__cdecl *)(void)' to 'WTF::Function<void (void)> &&'
    note: You cannot bind an lvalue to an rvalue reference

The problem might have something to do with cdecl vs. stdcall functions, but I am not sure that is the problem. It could be some other problem with how WTF::Function is written. Or it might even be a bug in the Visual Studio compiler. Since I don’t have a Windows machine myself, I was trying to use EWS to figure this out but that was slow. Then I tried using http://webcompiler.cloudapp.net but I could not reproduce any error there when I pasted in cut down code; it just compiled fine.

Is there someone who knows how to fix this?

Another way to put this is: We want to take off the explicit WTF::Function conversions in functions like canUseWithReason in SimpleLineLayout.cpp, Page::Page in Page.cpp, and Worker::Worker in Worker.cpp and have it still compile and work on Windows. Other platforms seem to compile fine without the explicit WTF::Function.

— Darin
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev


_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does someone know how to fix WTF::Function on Windows

Chris Dumez
I seem to remember I fixed it last time by calling the WTF::Function constructor explicitly.

Chris Dumez

On Jul 15, 2017, at 9:14 AM, Yusuke SUZUKI <[hidden email]> wrote:

I'm not 100% confident, but can you try it `&testFunction` instead?

Regards,
Yusuke Suzuki

On Sun, Jul 16, 2017 at 1:13 AM, Darin Adler <[hidden email]> wrote:
Hi folks.

On Windows, WTF::Function doesn’t quite work right. Code that is something like this:

    void addCallback(WTF::Function<void()>&&);

    void testFunction()
    {
        // ...
    }

    void addTestFunction()
    {
        addCallback(testFunction);
    }

Leads to errors like this:

    error C2664: 'void addCallback(WTF::Function<void (void)> &&)': cannot convert argument 1 from 'void (__cdecl *)(void)' to 'WTF::Function<void (void)> &&'
    note: You cannot bind an lvalue to an rvalue reference

The problem might have something to do with cdecl vs. stdcall functions, but I am not sure that is the problem. It could be some other problem with how WTF::Function is written. Or it might even be a bug in the Visual Studio compiler. Since I don’t have a Windows machine myself, I was trying to use EWS to figure this out but that was slow. Then I tried using http://webcompiler.cloudapp.net but I could not reproduce any error there when I pasted in cut down code; it just compiled fine.

Is there someone who knows how to fix this?

Another way to put this is: We want to take off the explicit WTF::Function conversions in functions like canUseWithReason in SimpleLineLayout.cpp, Page::Page in Page.cpp, and Worker::Worker in Worker.cpp and have it still compile and work on Windows. Other platforms seem to compile fine without the explicit WTF::Function.

— Darin
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Does someone know how to fix WTF::Function on Windows

Darin Adler
Right, that’s what I am looking to undo.

— Darin

Sent from my iPhone

On Jul 15, 2017, at 12:28 PM, Chris Dumez <[hidden email]> wrote:

I seem to remember I fixed it last time by calling the WTF::Function constructor explicitly.

Chris Dumez

On Jul 15, 2017, at 9:14 AM, Yusuke SUZUKI <[hidden email]> wrote:

I'm not 100% confident, but can you try it `&testFunction` instead?

Regards,
Yusuke Suzuki

On Sun, Jul 16, 2017 at 1:13 AM, Darin Adler <[hidden email]> wrote:
Hi folks.

On Windows, WTF::Function doesn’t quite work right. Code that is something like this:

    void addCallback(WTF::Function<void()>&&);

    void testFunction()
    {
        // ...
    }

    void addTestFunction()
    {
        addCallback(testFunction);
    }

Leads to errors like this:

    error C2664: 'void addCallback(WTF::Function<void (void)> &&)': cannot convert argument 1 from 'void (__cdecl *)(void)' to 'WTF::Function<void (void)> &&'
    note: You cannot bind an lvalue to an rvalue reference

The problem might have something to do with cdecl vs. stdcall functions, but I am not sure that is the problem. It could be some other problem with how WTF::Function is written. Or it might even be a bug in the Visual Studio compiler. Since I don’t have a Windows machine myself, I was trying to use EWS to figure this out but that was slow. Then I tried using http://webcompiler.cloudapp.net but I could not reproduce any error there when I pasted in cut down code; it just compiled fine.

Is there someone who knows how to fix this?

Another way to put this is: We want to take off the explicit WTF::Function conversions in functions like canUseWithReason in SimpleLineLayout.cpp, Page::Page in Page.cpp, and Worker::Worker in Worker.cpp and have it still compile and work on Windows. Other platforms seem to compile fine without the explicit WTF::Function.

— Darin
_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev

_______________________________________________
webkit-dev mailing list
[hidden email]
https://lists.webkit.org/mailman/listinfo/webkit-dev
Loading...