[postgis-tickets] [PostGIS] #4667: Fails to build with GCC-10
PostGIS
trac at osgeo.org
Fri Apr 17 06:16:22 PDT 2020
#4667: Fails to build with GCC-10
------------------------------------+------------------------
Reporter: Bas Couwenberg | Owner: Raúl Marín
Type: defect | Status: new
Priority: medium | Milestone:
Component: build/upgrade/install | Version: 3.0.x
Resolution: | Keywords:
------------------------------------+------------------------
Comment (by Bas Couwenberg):
That also looks like what the [http://gcc.gnu.org/gcc-10/porting_to.html
porting guide] documents:
> **Default to -fno-common**
>
> A common mistake in C is omitting `extern` when declaring a global
variable in a header file. If the header is included by several files it
results in multiple definitions of the same variable. In previous GCC
versions this error is ignored. GCC 10 defaults to `-fno-common`, which
means a linker error will now be reported. To fix this, use `extern` in
header files when declaring global variables, and ensure each global is
defined in exactly one C file. If tentative definitions of particular
variables need to be placed in a common block,
`__attribute__((__common__))` can be used to force that behavior even in
code compiled without `-fcommon`. As a workaround, legacy C code where all
tentative definitions should be placed into a common block can be compiled
with `-fcommon`.
>
> {{{
> int x; // tentative definition - avoid in header files
>
> extern int y; // correct declaration in a header file
> }}}
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4667#comment:6>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list