Skip to content

Fixes for modern compilers#80

Open
tvrusso wants to merge 2 commits into
PhirePhly:masterfrom
tvrusso:fixes_for_modern_compilers
Open

Fixes for modern compilers#80
tvrusso wants to merge 2 commits into
PhirePhly:masterfrom
tvrusso:fixes_for_modern_compilers

Conversation

@tvrusso
Copy link
Copy Markdown

@tvrusso tvrusso commented May 18, 2026

There are some relics in aprx that depend on behaviors of gcc prior to version 10. This leads to compilation failures with more recent compilers.

The issues are:

  • gcc after version 10 defaults to "-fno-common" which makes it an error to have global variables of the same name in two different files --- they are no longer assumed to be the same variable and lead to linker errors.
  • there are two places where an implicit "int" declaration was assumed, and modern compilers are more strict

This PR allows aprx to compile with compilers as recent as gcc14

tvrusso added 2 commits March 23, 2026 18:35
Compilers are now fairly strict about function arguments not being
declared and being assumed to be int.   This patch (taken from PhirePhly#78)
fixes that issue.
Modern versions of gcc (starting with version 10) default to
"-fno-common", which means that it is necessary to define global
variables in ONE file, and in all other files reference that variable
only by declaring it with an "extern" keyword.   This is not done in
aprx, which simply has multiple definitions of a few variables in
several different files.

In aprx.h, two variables were being defined (aprsis_thread and
pthr_attrs).   These same variables were then defined again in
aprsis.c.   aprsis.c is the only file where there is any use of
aprsis_thread.  Its use of pthr_attrs is only as a temporary in one
function.

This caused link failure because every file that included aprsx.h had
its own copy of those two global variables, even though none of them
needed the variables.

netresolver.c further has its own definition of a global pthr_attrs
that it only uses locally, so the variable is defined twice
there (once through aprx.h).

Since nobody needs pthr_attrs as a global variable, it should not be
in aprx.h and should be locally declared in the functions that use it.

Since only aprsis.c needs aprsis_thread and it already defines it
itself, it doesn't need it to be in aprx.h.

Finally, aprx-stat.c defines "now" as a global variable and so does timercmp.c,
causing exactly the same problem at link time.  Fortunately, this
one's easy because timercmp.c doesn't even *use* that variable, and
the simplest thing to do is to remove its definition.

Fixes PhirePhly#62
Fixes PhirePhly#72 (which is a duplicate of 62)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant