<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72038>72038</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Error about declaration in module following declaration in the global module
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rnikander
</td>
</tr>
</table>
<pre>
I found this while trying to use the `kqueue` API on macOS, but here is a minimal example that shows the same thing, I think, without needing the include.
There seems to a weird situation in C++ where you have to write `struct kevent` instead of just `kevent`, in order to declare a variable, because the C library has a struct and function with the same name.
`minimal.ccm`
```
module;
// #include <sys/event.h>
struct kevent { }; // <-- something like this is in that header on macOS
void kevent(int x); // <--
export module my_mod;
struct kevent evt;
```
And in my shell:
```console
/Dev/llvm-project/build/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -std=c++2b --precompile minimal.ccm -o minimal.pcm
minimal.ccm:6:8: error: declaration of 'kevent' in module my_mod follows declaration in the global module
6 | struct kevent evt;
| ^
minimal.ccm:3:8: note: previous declaration is here
3 | struct kevent { };
| ^
1 error generated.
```
This seems like a workaround...
```c++
module;
#include <sys/event.h>
using Renamed = struct kevent;
export module my_mod;
Renamed my_event;
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVUuv2zgP_TXKhojhSLl2vPAijwYoPnyYYtpFd4VsMbEaWfLokdz8-4FkJ7k3vZ0ahh8yRfIcHtLcOXnUiDV52ZCX3YwH3xlbWy1PXAu0s8aIa_0ZDiZoAb6TDi6dVAjeXqU-gjcQHILvEEiRn_4JGJAUOay_fAajoeftX18J3UITPHRoEaQDDr3UsucK8JX3Q3TWcQ-uMxeXPDnexzWpj3Hr5_R4io8X6TsTPGhEkaJ3CFK3KgjMgOQ7kq_H67cUyyH2LqbI4YLSCnDSB-6l0SA1bAndELqBS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