2

Can you get this to work in Xcode 11, c++20?

// file a.cppm (also tried naming it a.cpp or a.cc)
export module a;
int x;

// file b.cpp
import a;  // ERROR: Module 'a' not found.
int y;
y = x;

using clang c++2a I have tried everything and I have found no answer clear enough for me to understand. clang c++20 does not fully yet support modules according to its own: https://clang.llvm.org/cxx_status.html, but in another place https://clang.llvm.org/docs/Modules.html they state:

At present, there is no C or C++ syntax for import declarations. Clang will track the modules proposal in the C++ committee. See the section Includes as imports to see how modules get imported today...

... and hereafter, in the same doc, follows an explanation on how to use #include with modules "TODAY" that I can also not get working.

others also/explicitly relate that you can use modules with clang, eg. and according to this source, as of April 2019: https://www.phoronix.com/scan.php?page=news_item&px=Clang-Cpp20-Modules-Switch.

I'm sure that the intersection of clang ∩ c++20 modules ∩ Xcode is sufficiently big for there to tell exactly HOW (because I for one am convinced that it is possible) to implement the above example.

ps. I asked a similar question some time back c++20 modules (experimenting with Xcode 11). the answers there were little scarce and I'm asking/trying this again with new references.

Cœur
  • 37,241
  • 25
  • 195
  • 267
mrchance
  • 1,133
  • 8
  • 24
  • 1
    Please add the version of `clang` used for the tests. – Richard Critten Oct 21 '19 at 09:54
  • @RichardCritten as seen from terminal: clang-1100.0.33.8 – mrchance Oct 23 '19 at 08:49
  • 1
    It seems that clang on Mac has a strange version number (current release of clang is 9.0.0) see: https://stackoverflow.com/questions/50388290/how-can-i-find-the-actual-clang-version-on-mac So it's going to be difficult to cross-reference the clang docs against the version of clang on Mac. Also https://stackoverflow.com/questions/33603027/get-apple-clang-version-and-corresponding-upstream-llvm-version – Richard Critten Oct 23 '19 at 08:53
  • @RichardCritten, hmm, this is the full output from "clang -v" on terminal: Apple clang version 11.0.0 (clang-1100.0.33.8) Target: x86_64-apple-darwin19.0.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin – mrchance Oct 23 '19 at 09:04
  • 1
    @RichardCritten according to https://en.wikipedia.org/wiki/Xcode#Toolchain_versions it would seem that apples clang 11 is "based on" LLVM 8.0.0 (==clang 8?). since according to https://www.phoronix.com/scan.php?page=news_item&px=Clang-Cpp20-Modules-Switch you would need clang 9.0 to flip on modules, my question is, can i use/get clang 9.0 onto my xcode 11? – mrchance Oct 23 '19 at 09:40
  • 1
    See also this table for C++20 compiler support, including Apple Clang: https://en.cppreference.com/w/cpp/compiler_support. – deltacrux Nov 04 '19 at 00:55
  • https://stackoverflow.com/questions/63688639/c20-library-support-for-xcode-12/63690216?noredirect=1#comment112626458_63690216 – puio Sep 17 '20 at 20:56

0 Answers0