<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94138>94138</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang's `-Wmissing-prototypes` isn't helpful for explicitly `extern "C"` function definitions.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chandlerc
</td>
</tr>
</table>
<pre>
I really like `-Wmissing-prototypes` for a lot of stuff, but it is firing on one pattern where it seems pretty unhelpful:
```
toolchain/parse/parse_fuzzer.cpp:18:16: error: no previous prototype for function 'LLVMFuzzerTestOneInput' [-Werror,-Wmissing-prototypes]
18 | extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
| ^
toolchain/parse/parse_fuzzer.cpp:18:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
18 | extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
| ^
| static
```
The code in question is following LibFuzzer's documented guidance to define the fuzzer entry point:
```cpp
extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data,
std::size_t size) {
```
The warning is technically correct that this definition has no prior prototype. However, by making it `extern "C"` there is a very clear signal that this is a known C ABI external entry point that we need to define, but may not have a header to declare for us. And suggesting to add `static` when the function is declared explicitly `extern "C"` seems pretty confusing.
Ideally I'd like to just disable this warning for `extern "C"` functions as it seems unlikely to be correct. If folks are specifically interested in retaining that, I'd love a flag to control that narrow behavior.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0lc1u4zYQx5-GvgxiyLTlj4MOjlOjBrboZdE9LihyZHFDkyo5tNd5-mIkOc6i2QYosEIgxsZ4Pn4z86dKyR49YiXKR1E-TVSmNsRKt8obh1FP6mCu1QEiKueu4OwzglgWD19ONiXrjw9dDBTo2mESywKaEEGBCwShgUS5aYTcQZ0JLIFN0Nho_RGCh-AROkWE0cOlxYhskRBPCbqIRFfIvkXXNdmJ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