Closed joshuamaiche closed 4 months ago
For Windows I'm assuming use of MSVC or MSVC-like compiler: cl.exe, clang-cl, icl.exe, icx.exe.
I could potentially update DirectXMath to use fully qualified name resolution in these cases if that would help.
I tried it, and unfortunately fully-qualified name resolution won't work.
namespace DirectX
{
namespace Internal {}
inline namespace DX11 { namespace Internal {} }
}
means that while DirectX::DX11::Internal
is not ambiguous, DirectX::Internal
is.
The only solution that worked for me was just getting rid of the ambiguity. If DX11::Internal
really is internal, is there a big risk to its name being changed? I was able to get DirectXTK compiling on clang by changing DX11::Internal
to DX11::InlinedInternal
in ScreenGrab.cpp
and WICTextureLoader.cpp
, but I'm not sure if there are consequences I'm not seeing.
Let me know if you want me to put up a PR with those changes.
The use of Internal
in multiple contexts is the problem.
Ok, I propose that I change the DirectXMath library to use DirectX::MathInternal
, and DirectX Tool Kit for DX11 & DX12 to use DirectX::DX1?::ToolKitInternal
.
That should work, yes?
That should fix it, thanks!
Repro steps
Details The issue seems to boil down to the code becoming something like this:
Clang on Windows defaults to using
-fdelayed-template-parsing
to try to match how MSVC doesn't parse the template body until later in compilation. I'm not sure why, but for some reason,clang-cl
seems to parse the template before theInternal
namespace becomes ambiguous, andclang
seems to parse the template after the ambiguity is introduced. The parsing point seems inconsistent, but on Windows,clang
,clang-cl
, andcl
will all fail to compile the example code above. This might mean that it's just luck that MSVC and clang-cl currently compile when theDX11
namespace introduces an ambiguousInternal
namespace.One workaround for users is to switch to switch their project from
clang
toclang-cl
. If this isn't safe, an alternative could be to add the lineto their project, to disable delayed template parsing.