Yo Greg!

On Fri, 31 Oct 2025 07:34:48 -0400
Greg Troxel <[email protected]> wrote:

> I was boggled by this because fds are ints.
> 
> Reading the header, this seems crazy: it's either an int or a void*.
> Compilers may well warn on casting void * to long, as that's basically
> wrong.

I'm sorry, I seem to have missed the start of this thread?

gps_fd is much, much, more of a mess than you could ever suspect.

When Qt is not invalved, gps_fd is an integer.

When Qt is involved, gps_fd is a void*

Look in include/gps.h:

#ifdef USE_QT
    /* we want this to be QTcpSocket *, but that requires QTcpSocket.h, which
     * requires a bunch of other includes, that require __cpplus, and that
     * gets weird fast. */
typedef void* gps_fd_t;
#else
    /* socket or file descriptor to GPS
     * POSIX says this is an int.
     * use socket_t, which is int, for windows compatibility */
typedef socket_t gps_fd_t;
#endif

Yes, it is a big steaming pile, but it actually works.  I don't know Qt,
so I will not touch it unless something breaks.  The guy that did the
Qt stuff decided it was easier to reuse gpsd_fp instead of changing
a tone of function calls, adding #ifdef, etc.

For logging purposes, just treat gps_fd as a long, and it works for Qt, and
non-Qt.

If someone that knows Qt wants to fix this in a more elegant manner, then
have at it.  But it will be a large and invasive task.  Not something to dd
near a release.  My attitude, for now, is "Ain'y broke, don't fix it."

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        [email protected]  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpBza7Gxql3p.pgp
Description: OpenPGP digital signature

Reply via email to