As promised, I have published a Python script at
https://github.com/josuttis/cppmodules
The script circumvents the current restrictions of Visual C++ for simple C++ example that want to test modules. I hope this contribution will help to bring modules faster to life.
You can find the script with documentation and test code at the
web site. However let me mention a few basic aspects here.
Unlike Visual C++, the script
and to test this we have:
Calling:
clmod.py /std:c++latest modall_part.cppm modall_ifpart.cppm modall_if.cppm modall_impl.cpp modall_test.cpp /Femodall.exe
will automatically do the right thing:
cl /std:c++latest /Femodall.exe /TP /c /internalPartition modall_part.cppm
cl /std:c++latest /Femodall.exe /TP /c /interface modall_ifpart.cppm
cl /std:c++latest /Femodall.exe /TP /c /interface modall_if.cppm
cl /std:c++latest /Femodall.exe /TP /c modall_impl.cpp
cl /std:c++latest /Femodall.exe /TP /c modall_test.cpp
cl /std:c++latest /Femodall.exe modall_part.obj modall_ifpart.obj modall_if.obj modall_impl.obj modall_test.obj
Note that the order of the files still matters.
This example also works when using the Visual C++ conventions:
Thus, this script does not propose any file suffixes
as a convention.
Instead, you now can use any convention to be able to
have a first portable C++ program using modules just passing all
files to the compiler.
The script is not perfect. One drawback is that it requires
compilation by command line. The script is still a workaround
until Visual C++ provides this support directly (which should be
easy to do). But at least you can now make easy experience with
portable module examples not using an IDE.
Hope this helps.
Feedback welcome (please cc me directly as I have not
subscribed the SG155 reflector).
Nico
--
---
Nicolai M. Josuttis
www.josuttis.de
+49 (0)531 / 129 88 86
+49 (0)700 / JOSUTTIS
Books:
C++: http://cppstd20.com, http://cppstd17.com, http://cppmove.com,
http://cppstdlib.com, http://tmplbook.com