My project defines a module ocr, imports std and includes headers from a few libraries, for example:
module;
#include
#include
#include
module ocr;
import std;
It compiles with GCC 15 with -fmodules -fsearch-include-path bits/std.cc.
For Eclipse CDT LSP editor using clangd (LLVM 21), I first precompiled both modules:
clang -std=c++23 -stdlib=libc++ -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile -o std.pcm /usr/lib/llvm-21/share/libc++/v1/std.cppm
clang -std=c++23 -stdlib=libc++ --precompile -o ocr.pcm OCR.cppm
In .clangd in the Eclipse project I have:
CompileFlags:
Add: [-std=c++23, -Wall, -fmodule-file=std=std.pcm, -fmodule-file=ocr=ocr.pcm]
With that, the LSP editor (or clang when compiling on the command line) tells me:
OCR.cpp:69:32: error: reference to 'string' is ambiguous
69 | void OCR::readImage(const std::string &body,
| ^
/usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/stringfwd.h:79:33: note: candidate found by name lookup is 'std::string'
79 | typedef basic_string string;
| ^
/usr/lib/llvm-21/share/libc++/v1/std/string.inc:34:14: note: candidate found by name lookup is 'std::string'
34 | using std::string;
I suppose it is the two includes and that "pull in" libstdc++, causing the ambiguity with libc++.
Does it make sense at all what I am trying to do, can the ambiguity be resolved?