Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
decode_aprs.c: Limit __compar_fn_t to Linux
POSIX does not define __compar_fn_t.   Rather than using it, except on
a list systems where it does not exist, invert the conditional so that
it is used when it is known to exist, and on other systems --
including unknown systems -- use a POSIX-compatible invocation.

Probably switching on __linux__ isn't really right, and instead there
should be a feature test in cmake.  Alternatively, since passing
tocall_cmp without a cast doesn't result in warning, because it is the
same type except static, it would be simpler to just drop the use of
__compar_fn_t entirely.
  • Loading branch information
gdt committed Jan 4, 2022
commit a9732ee23c254d7c20e98e7b8f4dbeec8b4a2510
7 changes: 4 additions & 3 deletions src/decode_aprs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3935,10 +3935,11 @@ static void decode_tocall (decode_aprs_t *A, char *dest)
* models before getting to the more generic APY.
*/

#if defined(__WIN32__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)
qsort (tocalls, num_tocalls, sizeof(struct tocalls_s), tocall_cmp);
#else
#if defined(__linux__)
/* glibc defines __compar_fn_t, which is not defined by POSIX. */
qsort (tocalls, num_tocalls, sizeof(struct tocalls_s), (__compar_fn_t)tocall_cmp);
#else
qsort (tocalls, num_tocalls, sizeof(struct tocalls_s), tocall_cmp);
#endif
}
else {
Expand Down