GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libgomp

Fix libgomp build with '-Wc++-compat' for OpenACC host_dispatch

Libgomp's `host_dispatch` definition now avoids C++ compatibility issues with tentative definitions.

Building libgomp with the -Wc++-compat flag caused an error due to a C-style tentative definition of host_dispatch. This commit restructures the definition to be compatible with C++ standards, resolving the build error and ensuring correct compilation for OpenACC host code.

In Details

The libgomp/oacc-host.c file contained a C-style tentative definition for host_dispatch (static struct gomp_device_descr host_dispatch; followed later by static struct gomp_device_descr host_dispatch = ...;). This pattern is disallowed in C++ when strict compatibility flags like -Wc++-compat are enabled. The change adjusts the definition to conform to C++ syntax, likely by defining it directly without a prior tentative declaration or by using a different initialization approach.

For Context
libgomp
GCC's implementation of the OpenMP runtime library, providing support for parallel programming.
-Wc++-compat
A GCC compiler flag that warns about constructs that are valid in C but not in C++.
tentative definition
In C, a declaration of an identifier without an initializer that can also serve as a definition if no other definition is visible.
OpenACC
A directive-based programming standard for parallel computing that targets accelerators like GPUs.
Filed Under: libgompopenaccbuildc++ compatibility