boostorg / winapi

Windows API declarations without <windows.h>, for internal Boost use.
63 stars 55 forks source link

clang-cl compilation error #83

Closed egorpugin closed 4 years ago

egorpugin commented 4 years ago

Clang-cl from master. Removing :: fixes errors.

[sw.client.manager-0.4.2]/src/sw/manager/settings.cpp
In file included from D:/dev/cppan2/client2/src/sw/manager/settings.cpp:20:
In file included from D:/dev/primitives/src/log/include\primitives/log.h:13:
In file included from D:/dev/swst/pkg/8d/ed/6a12/src/sdir/include\boost/log/trivial.hpp:23:
In file included from D:/dev/swst/pkg/8d/ed/6a12/src/sdir/include\boost/log/sources/severity_logger.hpp:20:
In file included from D:/dev/swst/pkg/8d/ed/6a12/src/sdir/include\boost/log/detail/light_rw_mutex.hpp:39:
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(73,43): error: no type named '_RTL_SRWLOCK' in the global namespace; did you mean simply '_RTL_SRWLOCK'?
    ::InitializeSRWLock(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock));
                                          ^~~~~~~~~~~~~~
                                          _RTL_SRWLOCK
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(61,32): note: '_RTL_SRWLOCK' declared here
typedef struct BOOST_MAY_ALIAS _RTL_SRWLOCK {
                               ^
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(73,5): error: no member named 'InitializeSRWLock' in the global namespace; did you mean simply 'InitializeSRWLock'?
    ::InitializeSRWLock(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock));
    ^~~~~~~~~~~~~~~~~~~
    InitializeSRWLock
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(71,25): note: 'InitializeSRWLock' declared here
BOOST_FORCEINLINE VOID_ InitializeSRWLock(PSRWLOCK_ SRWLock)
                        ^
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(78,49): error: no type named '_RTL_SRWLOCK' in the global namespace; did you mean simply '_RTL_SRWLOCK'?
    ::ReleaseSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock));
                                                ^~~~~~~~~~~~~~
                                                _RTL_SRWLOCK
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(61,32): note: '_RTL_SRWLOCK' declared here
typedef struct BOOST_MAY_ALIAS _RTL_SRWLOCK {
                               ^
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(78,5): error: no member named 'ReleaseSRWLockExclusive' in the global namespace; did you mean simply
      'ReleaseSRWLockExclusive'?
    ::ReleaseSRWLockExclusive(reinterpret_cast< ::_RTL_SRWLOCK* >(SRWLock));
    ^~~~~~~~~~~~~~~~~~~~~~~~~
    ReleaseSRWLockExclusive
D:/dev/swst/pkg/3c/51/ca71/src/sdir/include\boost/winapi/srw_lock.hpp(76,25): note: 'ReleaseSRWLockExclusive' declared here
BOOST_FORCEINLINE VOID_ ReleaseSRWLockExclusive(PSRWLOCK_ SRWLock)
                        ^
... output stripped ...
Lastique commented 4 years ago

Removing :: is not the correct solution since we are casting to _RTL_SRWLOCK from Windows SDK, not from Boost.WinAPI. Same with functions.

I suspect, there's something odd with your Windows SDK if it indicates that it supports Windows Vista but doesn't define _RTL_SRWLOCK and related API. What Windows SDK are you using and does it define _RTL_SRWLOCK and under what conditions?

egorpugin commented 4 years ago

Removing :: is not the correct

That was a quick note.

What Windows SDK are you using and does it define _RTL_SRWLOCK and under what conditions?

I'm on the latest sdk - 10.0.19041. I think it's in global ns.

Upd.: Not sure, maybe just clang-cl issue? Since it's really from master.

Lastique commented 4 years ago

10.0.19041 is a pre-release version, the latest release is 10.0.18362. I'm not seeing any test failures with clang-cl 10.0 from VS 2019 and Windows SDK 10.0.18362.

Can you try with the released clang-cl and Windows SDK?

egorpugin commented 4 years ago

10.0.19041 is offered from VS installer, since win10 2004 is released. Not sure if it's pre-release version. I'll try with different compiler and sdk and report back.

egorpugin commented 4 years ago

clang-cl 9.0 + winsdk 10.0.18362.0 gives same error. Maybe some boost header skipped or msvc/clang def is not working to do proper include order?

Command line + output (clang-cl 9.0 + winsdk 10.0.18362.0). https://pastebin.com/iHu4ihnF

Lastique commented 4 years ago

In that log, I can see you're using clang 11, at least its headers are among the included ones.

I can see BOOST_USE_WINDOWS_H is defined, and I can see boost/winapi/basic_types.hpp gets included at some point, but I don't see windows.h being included (which it should). Which makes me think this is either a compiler issue, or some sort of a preprocessor bug, or your Boost source was modified somehow.

Can you prepare a small reproducer test?

egorpugin commented 4 years ago

I did not change clang headers, just left them from clang-11. I'll try to minify.

Lastique commented 4 years ago

Can you reproduce with vanilla released versions of components? No pre-released stuff, no leftover headers etc. please.

egorpugin commented 4 years ago

Switched clang headers, same result. (Minifying.)

egorpugin commented 4 years ago

Looks like I have such code to create error with clang cl (though msvc works).

#ifdef BOOST_USE_WINDOWS_H
#undef BOOST_USE_WINDOWS_H
#define REDEFINE_BOOST_USE_WINDOWS_H
#endif

#include <boost/stacktrace.hpp>

// remove following 3 lines to fix the issue with clang-cl
#ifdef REDEFINE_BOOST_USE_WINDOWS_H
#define BOOST_USE_WINDOWS_H
#endif

#include <boost/log/trivial.hpp>
egorpugin commented 4 years ago

Do not remember why I have such strange defs, maybe wrap older stacktrace versions. I use the latest boost. Removed them, works both on msvc/clang-cl.

Upd.: feel free to close, if you consider this not a bug.

Lastique commented 4 years ago

Ok, I see. Thanks for investigating.