c++20 import

参考链接:https://askubuntu.com/questions/1428832/compiling-c20-program-that-uses-modules-with-ubuntu-22-04

g++ -std=c++20 -fmodules-ts -xc++-system-header iostream
This creates a gcm.cache directory in the current directory, with content like

$ tree gcm.cache/
gcm.cache/
└── usr
    └── include
        └── c++
            └── 11
                └── iostream.gcm

4 directories, 1 file
g++ -std=gnu++20 -fmodules-ts -o hello hello.cpp
import <iostream>;

int main (int argc, char *argv[]) {
  std::cout << "hello" << std::endl;
  return 0;
}
文章目录