microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.44k stars 369 forks source link

Any plan for the C++ 20 modules support? #233

Open a1q123456 opened 1 month ago

a1q123456 commented 1 month ago

Hi,

I’m making a new project and I’m planning to use modules. I found this project a pretty nice starting point for DirectX 12 applications, but I also found that there are some difficulties in using it with C++ modules with ‘import std’, as this project uses C++ standard library header files but you can’t mix C++ standard header files with C++ standard library modules together. e.g. using ‘#include < vector >’ and ‘import std’ together.

I wonder if we’ve got a plan for C++ 20 modules support. I’m thinking about something similar to how C++ standard libraries support C++ modules and header files at the same time, which you don’t have to have different implementations for the same functionalities.

walbourn commented 1 month ago

I'm currently building using C++17 since that is broadly supported and quite robust at this point. I know C++20 is 'complete', but not everyone is moving to using it as of yet. If I understand correctly, at a minimum this library needs to use C++ Modules instead of the Standard C++ Library STL stuff to be compatible with your scenario, correct?

Also, do you use MSBuild or CMake?

a1q123456 commented 1 month ago

I'm currently building using C++17 since that is broadly supported and quite robust at this point. I know C++20 is 'complete', but not everyone is moving to using it as of yet. If I understand correctly, at a minimum this library needs to use C++ Modules instead of the Standard C++ Library STL stuff to be compatible with your scenario, correct?

Also, do you use MSBuild or CMake?

Thanks for replying. I’m using MsBuild and yes, the problem is that this library uses C++ STL header files. If I like, I could also use STL headers instead of STL modules, but I think header files will be less common in the future unless we need to export a macro e.g. assert() or errno

walbourn commented 1 month ago

Note that import std; is actually a C++23 feature, not a C++20 modules Standard feature.

In C++20 you can do import <vector>;. You can't do import std; until C++23.

a1q123456 commented 1 month ago

Yeah I think you’re right, but it just feels that header units are kind of a transition state between modules and headers so I didn’t choose to use them.