diff --git a/documentation/new-notes/PR-902.md b/documentation/new-notes/PR-902.md new file mode 100644 index 000000000..2cd0863c9 --- /dev/null +++ b/documentation/new-notes/PR-902.md @@ -0,0 +1,20 @@ +### Fix registration of DRVETs + +The C++ code generated in an IOC's `RecordDeviceDriver.cpp` file can fail +to compile if the Makefile building the IOC defines the `USE_TYPED_DRVET` +macro. Compiler errors caused by this bug will look something like this: + +``` +test_registerRecordDeviceDriver.cpp:198:15: error: +typedef 'drvet' cannot be referenced with the 'struct' specifier + 198 | static struct drvet *drvsl[] = { + | ^ +/epics/base-7.0/include/drvSup.h:38:21: note: declared here + 38 | typedef typed_drvet drvet; + | ^ +1 error generated. +``` + +[This PR](https://github.com/epics-base/epics-base/pull/902) +modifies the generated C++ code to resolve that problem, and adds a +driver to the example IOC template to catch regressions. diff --git a/modules/database/src/template/top/exampleApp/src/Makefile b/modules/database/src/template/top/exampleApp/src/Makefile index cf9e8cd8f..fac2eb207 100644 --- a/modules/database/src/template/top/exampleApp/src/Makefile +++ b/modules/database/src/template/top/exampleApp/src/Makefile @@ -9,7 +9,7 @@ include $(TOP)/configure/CONFIG # ADD MACRO DEFINITIONS BELOW HERE # Use typed rset structure (see 3.16.1 release notes) -USR_CPPFLAGS += -DUSE_TYPED_RSET -DUSE_TYPED_DSET +USR_CPPFLAGS += -DUSE_TYPED_RSET -DUSE_TYPED_DSET -DUSE_TYPED_DRVET # xxxRecord.h will be created from xxxRecord.dbd DBDINC += xxxRecord diff --git a/modules/database/src/template/top/exampleApp/src/devXxxSoft.c b/modules/database/src/template/top/exampleApp/src/devXxxSoft.c index f7befadc5..e9e2186a7 100644 --- a/modules/database/src/template/top/exampleApp/src/devXxxSoft.c +++ b/modules/database/src/template/top/exampleApp/src/devXxxSoft.c @@ -1,50 +1,67 @@ -/* SPDX-FileCopyrightText: 1998 Argonne National Laboratory */ - +/* SPDX-FileCopyrightText: 2026 UChicago Argonne LLC */ /* SPDX-License-Identifier: EPICS */ /* devXxxSoft.c */ -/* Example device support module */ -#include -#include -#include -#include +/* Sample device & driver support interfaces */ -#include "alarm.h" -#include "cvtTable.h" -#include "dbDefs.h" -#include "dbAccess.h" -#include "recGbl.h" -#include "recSup.h" -#include "devSup.h" -#include "link.h" +#include +#include +#include +#include +#include +#include +#include #include "xxxRecord.h" -#include "epicsExport.h" +#include -static long init_record(dbCommon *prec) +/* Device Support Routines */ + +static long init_record(dbCommon *pcommon) { - struct xxxRecord *pxxx = (struct xxxRecord *) prec; + struct xxxRecord *prec = (struct xxxRecord *) pcommon; - if (recGblInitConstantLink(&pxxx->inp, DBF_DOUBLE, &pxxx->val)) - pxxx->udf = FALSE; + if (recGblInitConstantLink(&prec->inp, DBF_DOUBLE, &prec->val)) + prec->udf = FALSE; return 0; } - -static long read_xxx(struct xxxRecord *pxxx) -{ - long status = dbGetLink(&(pxxx->inp), DBF_DOUBLE, &(pxxx->val), 0, 0); - /* If get was successful VAL is now defined */ +static long read_xxx(struct xxxRecord *prec) +{ + long status = dbGetLink(&prec->inp, DBF_DOUBLE, &prec->val, 0, 0); + + /* If get was successful VAL is now defined */ if (!status) - pxxx->udf = FALSE; + prec->udf = FALSE; return 0; } -/*Create the dset for devXxxSoft */ +/* devXxxSoft Device Entry Table */ xxxdset devXxxSoft = { - { 5, NULL, NULL, init_record, NULL }, + { 5, NULL /* report */, NULL /* init */, + init_record, NULL /* get_ioint_info */ }, read_xxx, }; epicsExportAddress(dset, devXxxSoft); + + +/* Driver Routines */ + +/* The report method is called by the iocsh command 'dbior'. + * Use level to show more or different information about + * the state of the driver software, connections etc. + */ +static long xxxReport(int level) { + printf("xxxDriver: Report called, level %d\n", level); + return 0; +} + +/* xxxDriver Entry Table */ +drvet xxxDriver = { + 2, + xxxReport, + NULL /* init, rarely used */ +}; +epicsExportAddress(drvet, xxxDriver); diff --git a/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd b/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd index dea0eebbf..78356bcf4 100644 --- a/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd +++ b/modules/database/src/template/top/exampleApp/src/xxxSupport.dbd @@ -2,5 +2,7 @@ # # SPDX-License-Identifier: EPICS +driver(xxxDriver) + include "xxxRecord.dbd" device(xxx,CONSTANT,devXxxSoft,"Soft Channel")