Guy Jennings wrote:
>
> 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
I also discovered this problem during testing about a week ago. This
appears to track with GNU C version 2.7.2 (I saw the bug when I compiled
with gcc 2.7.2 and I used the -O flag). I also arrived at the conclusion
that the use of "const" in the typedef for CA_SYNC_GID only leads to
problems - so I removed it. This should not require any change in
any of the CA clients. I recently committed this change to 3.13 beta
at APS.
If there is interest I will patch 3.12.
I have only seen this problem show up when compiling with gnu C/C++ 2.7.2
(which is not distributed with vxWorks 5.2).
Jeff
--
______________________________________________________________________
Jeffrey O. Hill Internet [email protected]
LANL MS H820 Voice 505 665 1831
Los Alamos, NM 87545 USA FAX 505 665 5107
- References:
- Problem with sync groups and C++ clients Guy Jennings
- Navigate by Date:
- Prev:
Problem with sync groups and C++ clients Guy Jennings
- Next:
Re: seqChanShow switches Rozelle Wright
- 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:
Problem with sync groups and C++ clients Guy Jennings
- Next:
How to connect to mbbo records? Len Lawrence
- 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
|