Use the typed device support interfaces when available#84
Conversation
This removes warnings and errors from recent C & C++ compilers.
| long (*write_ao)(struct aoRecord *prec); | ||
| long (*special_linconv)(struct aoRecord *prec, int after); | ||
| } aodset; | ||
| #endif |
There was a problem hiding this comment.
Dumb question, why are this definitions needed? I can't find any calls to write_ao or read_ai.
There was a problem hiding this comment.
These are typedefs for the record-specific device support extension tables (dsets) that were first published for these records in the generated *Record.h headers in EPICS 7.0.4. Older versions of EPICS defined them in the *Record.c implementation code and also required device support layers to define them (the struct aStats that I replaced here) but that isn't good modern coding practice, and newer C/C++ compilers are getting more strict and rejecting duplicate definitions like that. They also don't like our old DEVSUPFUN typedef, requiring that all function pointers fully define the function being called.
The EPICS 7.0.4 release made it possible for device supports to not have to provide or use their own dset definitions, and the device support routines inside Base are much shorter as a result. However for external modules like iocStats to still build against older EPICS versions the devices have to provide a compatible definition, which is only used when compiling with the old EPICS versions (they didn't define the HAS_aidset or HAS_aodset macros). If you look at the include/aiRecord.h file in EPICS 7.0.4 or later you'll see the same definitions as above.
The read_ai() and write_ao() members of the aidset and aodset structures are function pointers (not functions), and get called from their record type's process() routine through the prec->dset field. The prec->dset field actually points to the appropriate devAiStats or devAoStats tables defined below, so the calls in the record type actually go to the ai_read() and ao_write() functions as given in those tables.
This removes warnings and errors from recent C & C++ compilers.
Apparently it duplicates #66 (which I only just found) but that PR doesn't include similar changes to the devIocStatsString.c and devIocStatsWaveform.c files that this PR does.
I assumed the oldest Base version supported was 3.15, not sure if this will fail against 3.14 which I haven't tried.
Developed using Claude and a generic plan that I had it create from my drvIpac commits: