From: Gerhard Sittig Date: Sat, 17 Nov 2018 19:32:25 +0000 (+0100) Subject: new-driver: keep driver_info local to the api.c source file X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-util.git;a=commitdiff_plain;h=8cb6848a1f106540003ba76a5704769cf3dd0897 new-driver: keep driver_info local to the api.c source file There is a circular reference between the driver info structure (which lists callback routines) and a driver's routines (one of them may have to reference the driver info). Add a forward declaration, and keep the declaration and the implementation 'static' within the api.c source file. Otherwise linker issues may arise should developers put the declaration into protocol.h since it's marked as SR_PRIV in the template. --- diff --git a/source/drv-api.c b/source/drv-api.c index 3444fd6..6a1c20c 100644 --- a/source/drv-api.c +++ b/source/drv-api.c @@ -20,6 +20,8 @@ #include #include "protocol.h" +static struct sr_dev_driver {lib}_driver_info; + static GSList *scan(struct sr_dev_driver *di, GSList *options) {{ struct drv_context *drvc; @@ -131,7 +133,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) return SR_OK; }} -SR_PRIV struct sr_dev_driver {lib}_driver_info = {{ +static struct sr_dev_driver {lib}_driver_info = {{ .name = "{short}", .longname = "{name}", .api_version = 1, @@ -149,5 +151,4 @@ SR_PRIV struct sr_dev_driver {lib}_driver_info = {{ .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }}; - SR_REGISTER_DEV_DRIVER({lib}_driver_info);