llvm / llvm/llvm-project

[clangd] False `module_decl_not_at_start` with `extern` c include

Open
#189,582 8 comments 1 reaction 0 assignees View on GitHub
clang:modules clangd false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

I have a CPP23 Project compiling correctly, but `clangd` falsely throwing:
```
Module declaration must occur at the start of the translation unit (fix available) [module_decl_not_at_start]
```
In the case of
```cpp
module;
extern "C" {
#include "header.h"
}

export module ModuleName;
```
It happens *only* if `extern "C"` is there. Unfortunately, I require the `extern "C"` call, otherwise I get `undefined symbol` errors during linking.

Search found llvm/llvm-project#145274 but it doesn't seem to fit my case, so I open this issue.

```
clangd version 22.1.1 (https://github.com/llvm/llvm-project.git fef02d48c08db859ef83f84232ed78bd9d1c323a)
Features: windows
Platform: x86_64-w64-windows-gnu; target=x86_64-w64-mingw32'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.