1

I'm having trouble getting c++20 modules to work with Xcode (v11 beta5).

I'm trying this:

// 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;
  • I get the ERROR : "Build Time" -> "Parse Issue": Module 'a' not found.
  • there are no other warning/errors (and, therefore, it would seem that modules are supported by compiler/linker).
  • I note that the build created no precompiled module a.pcm.

My Xcode project build settings are: using clang gnu++2a language dialect + libc++. compiling with -fmodules-ts and -std=c++2a. also enabled "Enable Modules (C and Objective-C) [no option available for C++].

so, my questions:

  1. does Xcode (10 or 11) clang support c++20 modules? (I wish to avoid using headers)
  2. if so, what additional configurations do i have to do?

Do i perhaps have to specify explicitly/manually (as compiler arguments) any intermediate output (eg. precompiled .pmc files/paths)? that would however be contrary to the purpose of an IDE, but perhaps Xcode only provides partial support?

pkamb
  • 33,281
  • 23
  • 160
  • 191
mrchance
  • 1,133
  • 8
  • 24
  • 1
    Since clang doesn't support modules yet, I presume that Apple's build of clang also does not support modules yet. https://clang.llvm.org/cxx_status.html – Eljay Aug 19 '19 at 12:21
  • @Eljay. thx. at least as of april 14 2019 it should with the -std=c++2a enabled. https://github.com/llvm-mirror/clang/commit/cab7f1f7bc141ac88d15030088b311bd450b2c94. but if that is included/available in xcode 11, im not sure. surely the switch -std=c++2a is accepted within xcode, clang. – mrchance Aug 19 '19 at 12:38
  • 1
    If you need the most current available stable release of LLVM, you can use [brew](https://brew.sh/) and then `brew install llvm`. – Eljay Aug 19 '19 at 12:43
  • @Eljay. thx, i followed your advice, along with setting the path and rebooting. unfortunately, the "module not found" error remains. – mrchance Aug 19 '19 at 15:27
  • 1
    I don't have any more suggestions. Both modules and contracts are the two upcoming features that I am highly anticipating and excited about. I hadn't thought either has made it to the mainlines yet of any mainstream compiler. I think both features are very hard, and will take time before they land in any compiler's mainline. – Eljay Aug 19 '19 at 16:31

0 Answers0