Menu

#866 winpthreads: WINPTHREAD_API after type name causes errors in MSVC

v1.0 (example)
open
nobody
winpthreads (4)
5
2020-12-04
2020-11-27
Long Nguyen
No

For the fun of it, I tried hacking winpthreads to have it build on MSVC. So far I have created a custom CMakeLists.txt and ported the autotools build system to CMake. However, on my first build attempt, I get numerous errors in the public header files. Turns out MSVC doesn't allow for __declspec attribute to come after the type name. Is it possible to move it before the type name?

Related

Bugs: #866

Discussion

  • Kai Tietz

    Kai Tietz - 2020-11-30

    Hello,

    I think it would be better to keep them for gcc at the place they are
    ... gcc is sadly a bit picky about the place for it ... as VC is too.
    But why not using macro specific for gcc, and another set for VC,
    which are placed at their most beloved places?

    Btw great that you try to port winpthread for VC :)

    Cheers,
    Kai

    Am Fr., 27. Nov. 2020 um 16:55 Uhr schrieb Long Nguyen
    kurumigaming@users.sourceforge.net:


    [bugs:#866] winpthreads: WINPTHREAD_API after type name causes errors in MSVC

    Status: open
    Group: v1.0 (example)
    Labels: winpthreads
    Created: Fri Nov 27, 2020 03:55 PM UTC by Long Nguyen
    Last Updated: Fri Nov 27, 2020 03:55 PM UTC
    Owner: nobody

    For the fun of it, I tried hacking winpthreads to have it build on MSVC. So far I have created a custom CMakeLists.txt and ported the autotools build system to CMake. However, on my first build attempt, I get numerous errors in the public header files. Turns out MSVC doesn't allow for __declspec attribute to come after the type name. Is it possible to move it before the type name?


    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/mingw-w64/bugs/866/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

     

    Related

    Bugs: #866

  • Long Nguyen

    Long Nguyen - 2020-12-03

    Let me check to see if __declspec(dllexport) can be put before the typename on GCC. If it's possible then I'll change all of it.
    Also, does winpthreads on GCC passes all the tests in the test_pthread folder?

    Long Nguyen

     

    Last edit: Long Nguyen 2020-12-03
  • Long Nguyen

    Long Nguyen - 2020-12-04

    I just tested having __declspec(dllexport) before type names with both clang and gcc and it seems to work on both of them.

    Code used:

    // Compiles with Clang 12 and GCC 10.2
    #include <stdio.h>
    
    __declspec(dllexport) void hello();
    
    void hello()
    {
        puts("Hello");
    }
    

    Long Nguyen

     

Log in to post a comment.