EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  <19981999  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  Index 1994  1995  1996  1997  <19981999  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 
<== Date ==> <== Thread ==>

Subject: Re: beta12 & GPIB & Compiler Bug
From: Marty Kraimer <[email protected]>
To: [email protected]
Date: Mon, 28 Sep 1998 12:59:30 -0500
Benjamin Franksen wrote:
> 
> Marty Kraimer wrote:
> >
> > GPIB device support which is implemented by starting the John Winan's
> > template
> > has the statements:
> >
> > static struct devGpibParmBlock devSupParams;
> >
> > ...
> >
> > static struct devGpibParmBlock devSupParams = {
> > ...
> > };
> >
> > Note that this is legal ISO C but is not legal C++
> 
> I searched the 'bible' (K&R: The C Programming Language) and found no
> hint as to what the result of this should be. If one judges according to
> logic, the compiler should reject that as a multiple definition error.
> But in reality it seems the compiler believes that the first definition
> is meant as a declaration (even without 'extern' keyword) and so accepts
> it.
> 

K&R is not very clear about this "feature".

I found two other books which more clearly state that this is legal ISO
C but not legal C++.

C, A Reference Manual, Harbison and Steele, FORTH EDITION. Section 4.9.7
Defining and Referencing Declarations.

The C++ Programmintg Language, Bjarne Stroustrup, THIRD EDITION,
Appendix B, Page 818.


> However, IMO it is better to prefix the _declaration_ with 'extern'
> instead of 'static', i.e.
> 
> extern struct devGpibParmBlock devSupParams;
> 
> static struct devGpibParmBlock devSupParams = {
> ...
> };
> 

This is a solution if each GPIB device support modules uses a new name
instead of devSupParams.

This solves compiler bug but does not solve the C++ incompatibility.

Another way is to move the initialization to init_dev_sup. Thus instead
of

static struct  devGpibParmBlock devSupParms = {
  &Hp54540aDebug,          /* debugging flag pointer */
  -1,                   /* set to -1 if the device does NOT respond to
writes */
  TIME_WINDOW,          /* # of clock ticks to skip after a device times
out */
  NULL,                 /* hwpvt list head */
  gpibCmds,             /* GPIB command array */
  NUMPARAMS,            /* number of supported parameters */
  4,                    /* magic SRQ param number (-1 if none) */
  "devHp54540Gpib",     /* device support module type name */
  DMA_TIME,             /* # of clock ticks to wait for DMA completions
*/

  NULL,                 /* pointer to SRQ handler function (NULL if
none) */
  NULL                  /* pointer to secondary conversion routine */
};


We could have

static long init_dev_sup(int parm)
{

    devSupParms.debugFlag = &Hp54540aDebug;
    devSupParms.respond2Writes = -1;
    ...
}

This still does not solve the problem that all existing support will
need to be modified.
I still hope we can fix the problem with a later version of GNU C.

Marty Kraimer

References:
beta12 & GPIB & Compiler Bug Marty Kraimer
Re: beta12 & GPIB & Compiler Bug Benjamin Franksen

Navigate by Date:
Prev: Re: Channel counts? Karen S. White
Next: 32 channel PMAC boards William Lupton
Index: 1994  1995  1996  1997  <19981999  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: beta12 & GPIB & Compiler Bug Benjamin Franksen
Next: 32 channel PMAC boards William Lupton
Index: 1994  1995  1996  1997  <19981999  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 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·