Open lygstate opened 5 months ago
Similar to issue #58783.
Similar to issue #58783.
yeap, somewhat different, this have namespace and for C++ only, without the namespace, MSVC also have error message
I think Clang is correct to reject that code, per https://eel.is/c++draft/dcl.link#7 and https://eel.is/c++draft/basic.scope#scope-6: https://godbolt.org/z/nPc5451fv -- they don't declare the same entity and the names conflict.
CC @rnk @zmodem for opinions on whether this is behavior we should try to implement for compatibility. My inclination is to not support this construct unless there's a strong need; this feels like a bug more than an intentional behavior (unless I'm missing something).
I think Clang is correct to reject that code, per https://eel.is/c++draft/dcl.link#7 and https://eel.is/c++draft/basic.scope#scope-6: https://godbolt.org/z/nPc5451fv -- they don't declare the same entity and the names conflict.
CC @rnk @zmodem for opinions on whether this is behavior we should try to implement for compatibility. My inclination is to not support this construct unless there's a strong need; this feels like a bug more than an intentional behavior (unless I'm missing something).
I need this to export symbols to generate symbols to override windows sdk API, This is something I needed. I think this can be treat as warning instead of error(so that the warning can be disabled)
I think Clang is correct to reject that code, per https://eel.is/c++draft/dcl.link#7 and https://eel.is/c++draft/basic.scope#scope-6: https://godbolt.org/z/nPc5451fv -- they don't declare the same entity and the names conflict.
CC @rnk @zmodem for opinions on whether this is behavior we should try to implement for compatibility. My inclination is to not support this construct unless there's a strong need; this feels like a bug more than an intentional behavior (unless I'm missing something).
I agree with your inclination, we shouldn't do compatibility workarounds unless it's for code which a user cannot control such as Windows system headers. That doesn't seem to be the case here.
I need this to export symbols to generate symbols to override windows sdk API, This is something I needed. I think this can be treat as warning instead of error(so that the warning can be disabled)
If you just need to generate a symbol with the same name, can't you do it in a file which doesn't include windows.h?
I think Clang is correct to reject that code, per https://eel.is/c++draft/dcl.link#7 and https://eel.is/c++draft/basic.scope#scope-6: https://godbolt.org/z/nPc5451fv -- they don't declare the same entity and the names conflict. CC @rnk @zmodem for opinions on whether this is behavior we should try to implement for compatibility. My inclination is to not support this construct unless there's a strong need; this feels like a bug more than an intentional behavior (unless I'm missing something).
I agree with your inclination, we shouldn't do compatibility workarounds unless it's for code which a user cannot control such as Windows system headers. That doesn't seem to be the case here.
I need this to export symbols to generate symbols to override windows sdk API, This is something I needed. I think this can be treat as warning instead of error(so that the warning can be disabled)
If you just need to generate a symbol with the same name, can't you do it in a file which doesn't include windows.h?
Yeap, because I am trying to override Windows.h's api, I depends on that :(
It seems this is same as issue #24569, #29512.
Code to reproduce the issue
With cl.exe, it's compiles fine.
With clang-cl.exe, it's fails with