On Monday 24 August 2015 14:26:12 Hovanes Egiyan wrote:
Hi,
I was trying to call SNLs C-functions equivalents for pvPut, pvGet,
pvAssign etc (seq_pvPut ...)
from a C++ code using seq-2.1.12, and run into a compile-time problem.
I was getting error messages from g++:
/gluex/controls/epics/R3-14-12-3-RHEL5/support/seq-2.1.12/include/seqC
om.h:102: error: conflicting declaration ‘typedef const struct seqChan
seqChan’
/gluex/controls/epics/R3-14-12-3-RHEL5/support/seq-2.1.12/include/seq
Com.h:102: error: ‘struct seqChan’ has a previous declaration as
‘struct seqChan’
/gluex/controls/epics/R3-14-12-3-RHEL5/support/seq-2.1.12/include/seq
Com.h:103: error: conflicting declaration ‘typedef const struct
seqState seqState’
/gluex/controls/epics/R3-14-12-3-RHEL5/support/seq-2.1.12/include/seq
Com.h:103: error: ‘struct seqState’ has a previous declaration as
‘struct seqState’
/gluex/controls/epics/R3-14-12-3-RHEL5/support/seq-2.1.12/include/seq
Com.h:104: error: conflicting declaration ‘typedef const struct seqSS
seqSS’
/gluex/controls/epics/R3-14-12-3-RHEL5/support/seq-2.1.12/include/seq
Com.h:104: error: ‘struct seqSS’ has a previous declaration as ‘struct
seqSS’
The problem seems to be coming from seq-2.1.12/src/seq/seqCom.h header
file where there are typedef
statements for struct structure before actual definition of the
structures. C++ does not
seem to like it, and I was able to move forward using one "#ifndef
__cplusplus" instruction :
#ifndef __cplusplus
typedef const struct seqChan seqChan;
typedef const struct seqState seqState;
typedef const struct seqSS seqSS;
typedef struct seqProgram seqProgram;
#endif
/* Static information about a channel */
struct seqChan
{
...
That way these typedefs are not be present for a C++ compiler.
I do not know if it breaks anything in the bigger picture,
Well, the typedefs in question have a 'const' in them, so there is a
semantic difference. The better solution would be to rename either the
typedefs or the struct names.
but if it
does not, may be it could
be included in the "src/seq/seqCom.h" for the seq module.
I am reluctant to make this change on the 2.1 branch because there is no
longer any development happening there except critical bug fixes. The
problem should not appear with version 2.2, where I have separated the
definitions that are (meant to be) used only by the generated C code
(including the 'typedef const struct xxx' definitions that are causing
your problem) into a separate header file.
So, unless there is strong demand for it, I'd rather point you to
version 2.2 if you need to call pv functions from C++.
Cheers
Ben
________________________________
Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V.
Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph
Geschäftsführung: Prof. Dr. Anke Rita Kaysser-Pyzalla, Thomas Frederking
Sitz Berlin, AG Charlottenburg, 89 HRB 5583
Postadresse:
Hahn-Meitner-Platz 1
D-14109 Berlin
http://www.helmholtz-berlin.de