Epics folk:
I recently ran into a problem while attempting to use a sync group from
a C++ client application. The code below is based on acctst.c in the
epics
distribution.
/* int ca_sg_create(const unsigned int *g); */
int status;
CA_SYNC_GID gid=0; /* const unsigned int gid = 0; */
printf("Initially %ud\n", gid);
status = ca_sg_create(&gid);
SEVCHK(status, NULL);
printf("Then %ud\n", gid);
If compiled with gcc the code works fine, with the ca_sg_create call
initialising
'gid' to a non-zero value (45 in my case). If compiled with g++ the
code does not
work correctly and 'gid' retains the value 0 after the call to
ca_sg_create. This
appears to be due to the definition of CA_SYNC_GID as 'const unsigned
int'. I think
it would be safer to remove the const from the typedef for CA_SYNC_GID
since at
present you are relying on undefined behavior - (typecasting away the
const in
ca_sg_create).
As far as I can tell, CA_SYNC_GID is the only epics-defined type which
displays this
problem and the header already allows for CA_SYNC_GID not to be 'const'
Guy Jennings
BESSRC CAT
Argonne National Laboratory
- Replies:
- Re: Problem with sync groups and C++ clients Jeff Hill
- Navigate by Date:
- Prev:
seqChanShow switches Sean Prior
- Next:
Re: Problem with sync groups and C++ clients Jeff Hill
- Index:
1994
1995
<1996>
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: seqChanShow switches Rozelle Wright
- Next:
Re: Problem with sync groups and C++ clients Jeff Hill
- Index:
1994
1995
<1996>
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|