Closed LepelTsmok closed 7 years ago
DirectXTK is not likely to build fully with clang, even using the Microsoft codegen clang. In particular, any place I make use of C++/CX extensions (/ZW
) will not work as they are unsupported by clang (some versions of the input classes and the audio implementation).
It should be possible to build portions of the library, but it's likely to take some effort to work through it all. I do use VS 2017's /permissive-
to make the code as portable as possible, but it's obviously not catching everything.
You also should create a fresh clang static library VC++ project instead of trying to use one of the existing vcxproj
files. A number of those warnings are because the Microsoft clang-cl does not support all the options that Visual C++ cl does.
-frtti
D3D11_NO_HELPERS
and D3D11_VIDEO_NO_HELPERS
to get the Direct3D 11 Windows SDK headers to even build with clang. This is a problem since we use D3D11CalcSubresource
, CD3D11_TEXTURE2D_DESC
, and CD3D11_SHADER_RESOURCE_VIEW_DESC
.Trying to build with clang, I see:
Src\PlatformHelpers.h
is just a typo that I cut & pasted elsewhere. Fixed those easily.template<>
is easy enough. It looks like something that VC++ just ignores, but clang is a bit pickier about. I fixed these.XMVECTORF32
usage resulting in -Wmissing-braces
stuff is something I already cleaned up in DirectXMath. Shouldn't be hard to clean it up here; just tedious. I fixed these.#pragma prefast
should be guarded with #ifdef _PREFAST_
which is what I did in DirectXMath. I fixed these.-Wreorder
issues, but a few of them are there specially to work around some issues with VS 2013 w.r.t. to uniform initialization (which I still support, but will drop at some point). You might have to live with those for a while.XMVECTOR
overloads won't build with clang (see this commit) so has to be changed to use explicit function calls instead. This is particular problematic in the geometry header. I've left this as it was because this would reduce the readability in a number of places.How did you get past the problems with wrl.h
not working with clang? At a minimum, you need wrl\client.h
to define Microsoft::WRL::ComPtr
.
I should probably do a cleanup pass for DirectXTK, DirectXTK12, DirectXTex, and DirectXMesh trying to use clang. Remember that Microsoft clang-cl is experimental. so I'm not sure how good the resulting codegen is here, but it does find conformance bugs missed by
/permissive-
. It's also a problem that thewinrt
include folder in the Windows SDK doesn't really work with clang.
In short, I don't think you can build DirectXTK with clang because the Windows SDK itself doesn't support it, at least not with the current Windows SDKs.
I've run through DirectXTK, DirectXTK12, DirectXTex, and DirectXMesh trying to build them with clang. The latest DirectXMath lets you get that part building, but neither the Windows 8.1 SDK or Windows 10 SDK (15063) really supports building with clang: Direct3D 11 headers, Direct3D 12 headers, the D3DX12 utility header, and the Windows Runtime Library (WRL) don't build with clang. This might be fixed in some future release, but it's not there yet.
I did take the opportunity to clean up a number of the issues in my source, but not all of them. Notably I don't support the _XM_NO_XMVECTOR_OVERLOADS_
scenario in these libraries. I could, but it makes the code a lot messier and right now that doesn't really buy you anything.
Really the Microsoft clang support is intended for building libraries (static libs or DLLs) that are hosted in a larger Visual C++ built program. As such, your Direct3D 11 program should be built using Visual C++ and not clang, linking with DirectXTK built with Visual C++, and perhaps linked to other code (not Windows platform specific) built with Microsoft clang.
If a future release of the Windows 10 SDK supports clang for Win32 development more fully, I can try again and resolve the outstanding issues. In the meantime, DirectXMath itself is just well ahead of the rest of the Windows 10 SDK in supporting clang.
Hello DirectXTK-Team,
I'm a huge fan of your work and of the clang compiler. So I decided to make a project with both of them. I had compiled the DirectXTK library with the Visual Studio 2015 compiler and used it for my project with clang-cl. The result wasn't satisfying, because my program wasn't able to display the texture which I successfully loaded with DirectXTK. Compiling the code with the microsoft compiler showed the texture. So I wanted to compile the DirectXTK library with clang-cl and the new DirectXMath library. But it failed, with the following errors:
Kind regards LepelTsmok