<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130452>130452</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][OpenMP] The include file <omp.h> doesn't compile in C89 mode (it uses the "inline" keyword)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
quake33
</td>
</tr>
</table>
<pre>
Hello,
Clang 14.0.6 fails to compile the following program (`main.c`):
```c
#include <omp.h>
int main(void) {
return 0;
}
```
The command producing the error is:
`clang -std=c89 -fopenmp main.c`
The error message is:
```
In file included from main.c:1:
/usr/lib/llvm-14/lib/clang/14.0.6/include/omp.h:493:12: error: unknown type name 'inline'
static inline int omp_is_initial_device(void) { return 1; }
^
1 error generated.
```
I obtained Clang from the official Debian (stable) package.
I think this issue is still relevant today because the keyword `inline` is still written [in the include file <omp.h>](https://github.com/llvm/llvm-project/blob/1649ca5af07a40948ea409ca055330bec1419e72/openmp/runtime/src/include/omp.h.var#L504).
The problem is that `inline` is not a known keyword in C89. Therefore I propose to change [this](https://github.com/llvm/llvm-project/blob/1649ca5af07a40948ea409ca055330bec1419e72/openmp/runtime/src/include/omp.h.var#L502):
```c
# if defined(_OPENMP) && _OPENMP >= 201811
#pragma omp begin declare variant match(device={kind(host)})
static inline int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(nohost)})
static inline int omp_is_initial_device(void) { return 0; }
#pragma omp end declare variant
# endif
```
into this :
```c
# if defined(_OPENMP) && _OPENMP >= 201811
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#pragma omp begin declare variant match(device={kind(host)})
static inline int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(nohost)})
static inline int omp_is_initial_device(void) { return 0; }
#pragma omp end declare variant
# else
#pragma omp begin declare variant match(device={kind(host)})
static int omp_is_initial_device(void) { return 1; }
#pragma omp end declare variant
#pragma omp begin declare variant match(device={kind(nohost)})
static int omp_is_initial_device(void) { return 0; }
#pragma omp end declare variant
# endif
# endif
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVttu4zYQ_Rr6ZbAGL5IlPfjBiddogL2hu-irQVFjiQ1FqiTlIH9fUJKTbNJdYC9YtEAFgzYl8XjmnEPOyBB0axG3JL8i-X4lx9g5v_1rlLcoxKp2zf32NzTGEX5N6I7Q3bWRtgWWrel6AyepTYDoQLl-0AYhdggnZ4y707aFwbvWyx4IL8mG9lLbtSIbSnhFxG6GS9Ppo9KEC22VGRsEIq5dP6w7Il7PL2obISEQXp6dbgivgBRXhO4APMbRW6BEpDkp9k9x59WfOkwx9tI2KapmVCm-FC167zzo8DQiNeX4KsSGiL0qK3h1cgPafoDHHB5gZ4AeQ5AtPgN6COHGwinxs6TXwMm7_oImdmxZxA9j8IQfjK7TaM79K5Y9zKewCD_M5BN-WNAIPyxc7bJKJDhOxG4OLP0Y7a11dxbi_YBgZY9AeKGt0RYJLyYKAUKUUSuYb0Ni2_XDUYejtjpqaY4NnrXCz-m_UM-IuIKZeHi8SJ60YwtDLVr0MmKzfinPDbg6Sm2xgdlfEz1JHnc6aaWlgT3WWtpkpRBlbTBFMEh1K1tcX0Bip-1tGgPoEMakBoSojQGPBs_SRoiukfdQo5JjmO16i_d3zjdANnThZEMfF955HSNaIPmVttP7F4dOej61ab4nvOxiHCYL8APhh1bHbqzXyvWLnBdVB-_-RBUJP9TGJW3ZJquUzOWJFjKjVVZi-lKS5rkQtEbFMlZhwZPWkxUJP_jRRt0n-YNXL-2wPktPuHiT04zwaiFpMe3gXW2wT3nGTsYXyVsXQcJsmwtB2sJ1Wa3hU4ceT84j3CScwSUiHahO2hYTUUmAfzEb_GvnD-gTNHhKViS8PL7_8Prd2w-T2_mG8A0sdyAJLvbAKSsZW2xPuBi8bHuZtg7U2GoLDSojPcJZei2n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