2

I am using clang (from LLVM version 7.00) on Windows via clang-cl.

I am trying to get C++ Modules to work. I have tried the clang command line arguments -fmodules-ts and -fmodules.

I have also tried the msvc command line arguments (which work under MSVC - I am using 15.8.5) /experimental:module /module:interface (which would be the normal way for non-experimental options).

All options result in the error clang-cl.exe: warning: unknown argument ignored in clang-cl.

Anyone know if it's possible to use the C++ Modules TS under clang-cl?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
keith
  • 5,122
  • 3
  • 21
  • 50
  • 1
    Have you checked `clang-cl --help` and `man clang-cl` whether it lists those options? – Martin Ueding Sep 24 '18 at 15:06
  • @MartinUeding given that clang-cl will pass any unrecognised commandline argument through to the clang backend, I don't see how this helps. – keith Sep 24 '18 at 15:41
  • You could try `build2`. I wrote a [tiny preprocessor](https://github.com/aaron-michaux/mobius) for the `ninja` build system that has a modules-ts example. I've only tried it on Ubuntu. If you can read bash, then you should be able to adapt it to windows. – Zendel Nov 18 '18 at 20:56
  • @Zendel, or I could just write my own compiler :-) Unfortunately clang-cl is a strange beast (clang it ain't). – keith Nov 19 '18 at 10:27

2 Answers2

3

Use option -Xclang, like this:

clang-cl -Xclang -fmodules
Jan Joneš
  • 777
  • 6
  • 13
0

To enable C++ modules support you will need latest clang 10.0 release (suspect so), that one can be downloaded from this URL, as latest snapshot build:

https://llvm.org/builds/

With Visual studio 2019 / windows - checkout following git repository:

git clone https://github.com/NTSFka/CMakeCxxModules.git

Open folder with Visual studio 2019, from Configuration > Managed configurations

Add x64-CLang-Debug configuration, select it.

Check "Show advanced variables" and in CMAKE_C_COMPILER select

C:/Program Files/LLVM/bin/clang.exe

and from CMAKE_CXX_COMPILER select

C:/Program Files/LLVM/bin/clang++.exe

Compile program.

What I have tested by myself intellisense works, but still some text is displayed in red color (vs2019, 16.3.7), situation might change with Visual studio updates.

TarmoPikaro
  • 4,723
  • 2
  • 50
  • 62