#clangd is has issues when module import is in a header file, and not the cpp file. This is not a problem for clang, its all in the same translation unit. AFAICT this is legal and fine C++20 module code, clangd shouldn't have this issue.

https://github.com/llvm/llvm-project/issues/181770

#cpp #cplusplus #cppmodules #llvm #programming

[clangd] import from #include not working · Issue #181770 · llvm/llvm-project

Code which is valid for C++20 modules being built by clang is not working for clangd. If an import is done within a header that gets #include'ed its as if the import didn't happen for that translat...

GitHub

@hiddenalpha with brew it seems to come already with gcc. however, the bmi for the standard library is generated. I am as far as i got the last time when trying this. Import std worked then, when std.cc compiled together with my main.cpp but I couldn't figure out how to link the libstc++ then successfully.

#Cplusplus #cpp #modules #cmake #cppmodules #importstd

Did anybody successfully use C++ import std; on a mac with G++-15 and cmake 4.2.3 ?
I got as far as a linker error missing std module init and am too much of a cmake newbie to figure out anything working.

#cpp #cppmodules #cppimportstd #cmake

Found bug in clang-tidy with C++20 modules. A single check can conflict with itself.

https://github.com/llvm/llvm-project/issues/178102

#cpp #cplusplus #cppmodules #llvm #programming

Modules cause `performance-trivially-destructible` to conflict with itself · Issue #178102 · llvm/llvm-project

File: CMakeLists.txt cmake_minimum_required(VERSION 3.28) project(clang_tidy_bug CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_library(mymodule) target_sources(mymodule ...

GitHub

[EDIT: this is wrong, read thread]

Interesting #clangtidy issue.
When using #cppmodules its possible to have a fixit applies multiple times causing incorrect code.

I believe what is happening is the cppm is the source text, but its analysed in other translation unit by the module import which uses its pcm. In parallel they both read and apply their fixit and you get situations like NULL becoming nullptrptr.

I'll try and make a minimal example at some point.

#cpp #cplusplus

Any diagnostic to find cyclic dependencies?

set(CMAKE_CXX_SCAN_FOR_MODULES ON)
add_library(A STATIC)
target_sources(A PUBLIC
FILE_SET CXX_MODULES FILES mod.cppm # export module x;
)
target_link_libraries(A PRIVATE B)
add_library(B STATIC use.cpp) # import x;
target_link_libraries(B PRIVATE A)

All you get ATM is failure at compile time `fatal error: module 'x' not found`

But it would be nice to know that the real issue is that A and B make a cycle

#cplusplus #cppmodules #programming

What is the reasonable way to test internal parts of a module?

For a complex module I want unit tests for parts that I do not want to export. Do I make an internals module that can be tested. Then have the actual module which only re-export what I intend to be the library's interface?

#cpp #cplusplus #programming #cpp20 #cppmodules

Working with #cpp20 #cppmodules with #ninjabuild and #cmake

How can I run just the scan/dynamic based bits so that I can run clang-tidy without a full build?

ATM I have this hack
```
# cmake config
cmake --preset thing

# select what I need made
ninja -C build -t inputs | grep -E '\.cppm\.o$|\.o\.modmap$' | xargs -r ninja -C build

# then I can run clang-tidy
```

There must be a better way

#cpp #cplusplus #programming

Are We Modules Yet?