Open
Description
Hello,
Clang 14.0.6 fails to compile the following program (main.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>.
The problem is that inline
is not a known keyword in C89. Therefore I propose to change this:
# 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:
# 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