[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Program fails to compile after 3.20 upgrade
From: |
Charles Curley |
Subject: |
Re: Program fails to compile after 3.20 upgrade |
Date: |
Fri, 22 May 2020 07:13:11 -0600 |
On Fri, 22 May 2020 10:37:46 +0100
"David J Taylor" <address@hidden> wrote:
> My GPS monitoring program here:
>
> https://www.satsignal.eu/raspberry-pi/monitoring.html#gps
>
> fails to compile after upgrading to 3.20 (it used to work). My C
> isn't good enough to know how to specify the extra arguments which
> are required. Compiler output:
>
> --------------------------------------
> pi@RasPi-22:~ $ gcc gpsGetSatellites.c -o gpsGetSatellites -lgps
> gpsGetSatellites.c: In function �main�:
> gpsGetSatellites.c:26:14: error: too few arguments to function
> �gps_read� status = gps_read (&gpsdata);
> ^~~~~~~~
> In file included from gpsGetSatellites.c:12:
> /usr/include/gps.h:2307:12: note: declared here
> extern int gps_read(struct gps_data_t *, char *message, int
> message_len); ^~~~~~~~
> --------------------------------------
Right, the API changed a while ago. gps_read() now takes three
parameters.
To keep backward compatibility, you might use conditional compilation:
#if GPSD_API_MAJOR_VERSION >= 7
/* from <gps_json.h> */
#define GPS_JSON_RESPONSE_MAX 4096
bool showMessage = false;
char gpsdMessage[GPS_JSON_RESPONSE_MAX];
size_t gpsdMessageLen = 0;
#endif
....
#if GPSD_API_MAJOR_VERSION >= 7 /* API change. */
if (gps_read (&gpsdata, gpsdMessage, gpsdMessageLen) == -1) {
#else
if (gps_read (&gpsdata) == -1) {
#endif
If you don't care about the message, you can use NULL and 0 with
appropriate casts instead. gpsd will then ignore them.
I hope that helps.
--
Does anybody read signatures any more?
https://charlescurley.com
https://charlescurley.com/blog/