Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019 
<== Date ==> <== Thread ==>

Subject: Re: "Size of symbol changed" warnings building EPICS Base 3.14.12.2
From: Dirk Zimoch <dirk.zimoch@psi.ch>
To: Andrew Johnson <anj@aps.anl.gov>
Cc: tech-talk@aps.anl.gov
Date: Tue, 20 Mar 2012 17:58:29 +0100
Andrew Johnson wrote:
Hi Dirk,

Interesting, good detective work!

On 2012-03-20 Dirk Zimoch wrote:
In cac.cpp we find:
#define epicsAssertAuthor "Jeff Hill johill@lanl.gov"

But in templateInstances.cpp epicsAssertAuthor is not defined.

So does defining it there fix the problem?

- Andrew

It will remove the warning. But is that a fix?

Consider code where epicsAssertAuthor is A where the template is inlined and B where the template is explicitly instantiated. Depending on the Optimization flag, you get different behavior! Here, is it only a message text, but it may be worse.

BEWARE: PHILOSOPHY!

It seems that using macros, including 'assert', in any inline code is simply wrong programming. However, I cannot remember that I have ever seen such a statement in any C++ book. It seems logical when you consider what inline means and what macros are made for. They are simply incompatible. But typically C++ books only say things like: "With C++ inline code, you don't need macros any more. Inline code is much better, type safe, etc than macros." Unfortunately that is a lie. It is hard to get inline code right and you cannot do everything with inline code that you can do with macros.


Of course something like

template <class T>
T max(T a, T b) { return (a < b) ? b : a; }

is better than

#define max(a,b) ( (a) < (b) ? (b) : (a) )

when used in a context like max(getchar(), i++)

But often life is is more complicated than this.

Inline code is better than macros if you are a very experienced and professional C++ programmer. Otherwise you will suffer from the one million pitfalls in C++. And still you cannot do something like 'assert' in C++ inline code.

END PHILOSOPHY.

Maybe this is the wrong part:

#ifndef epicsAssertAuthor
#   define epicsAssertAuthor 0
#endif

In base, only Jeff ever sets epicsAssertAuthor. So we can replace it with a constant :-)

Dirk









References:
"Size of symbol changed" warnings building EPICS Base 3.14.12.2 J. Lewis Muir
Re: "Size of symbol changed" warnings building EPICS Base 3.14.12.2 Dirk Zimoch
Re: "Size of symbol changed" warnings building EPICS Base 3.14.12.2 Andrew Johnson

Navigate by Date:
Prev: Re: 32-bit TIFFs and PIL J. Lewis Muir
Next: RE: 32-bit TIFFs and PIL Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019 
Navigate by Thread:
Prev: Re: "Size of symbol changed" warnings building EPICS Base 3.14.12.2 Andrew Johnson
Next: ASYN Communication through windows serial port (via USB) Josh Stein
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  2019 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·