Skip to content

Support C++ modules for Bazel #8123

@bac-ptit

Description

@bac-ptit

Description of the feature request:

Bazel 9.0.0 officially supports C++ modules. I found an example in this repository: bazel_cxx20_modules_demo

load("@rules_cc//cc:defs.bzl", "cc_binary")

cc_binary(
    name = "demo",
    srcs = ["main.cpp"],          # Source files
    copts = ["-std=c++26"],       # Enable C++26
    features = ["cpp_modules"],
    module_interfaces = ["hello.cppm"],  # Module Interface File
)

When I create the BUILD.bazel file like this, Bazel builds successfully—both in the terminal and when using the CLion “Run” button.

However, code autocompletion doesn’t work: keywords turn red, and suggestions no longer appear. Despite this, the build itself works fine.

Image Image

Which category does this issue belong to?

CLion

What underlying problem are you trying to solve with this feature?

I’ve been using header files as a workaround, but since I’m following a modern C++ approach, I really need proper C++ modules.

What operating system, Intellij IDE and programming languages are you using? Please provide specific versions.

CLion: Windows Remote Development into Ubuntu 24.04

Have you found anything relevant by searching the web?

I haven’t found any solution yet, probably because C++ modules support in Bazel is very new—it was only released about two months ago.

Any other information, logs, or outputs that you want to share?

No log, Bazel compile successfully

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions