[Cbc] Compiler warning flags

Alpár Jüttner alpar at cs.elte.hu
Fri Apr 29 15:13:08 EDT 2011


Hi Stefan,


> The only one I modified was the one that defines variables for 
> COIN_DBL_MAX & co. I am not sure whether the compiler will substitute 
> the variables out,


I think you can be quite sure about it. Const values in C++ are designed
to be a full replacement for the constant definition by #define in C.
They can be put into the header files exactly to allow inlining and
optimization.

Regards,
Alpar

>  which I guess was desired by the CoinUtils 
> projectmanager when he decided for defines.
> 
> Stefan
> 
> > Hi,
> >
> > I made an attempt to weed out compilation warnings from Cbc using strict
> > warning flags with gcc 4.5.2. Please find the result in the attached
> > patches. They are against SVN version -r1638 of Cbc trunk. They contain
> > modifications of projects Cbc, Cgl, Clp, CoinUtils and Osi.
> >
> > I tried to remove the warnings that appeared using the following
> > configuration of Cbc:
> >
> > ./configure ADD_CXXFLAGS="-W -Wunused -Wctor-dtor-privacy
> > -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings
> > -Wno-char-subscripts -Wcast-align -Wsign-promo -Woverloaded-virtual
> > -fno-strict-aliasing -Wold-style-cast"
> >
> > The resulting patches contain the following changes:
> >
> >        * Every appearance of DBL_MAX was replaced by COIN_DBL_MAX.
> >        * All the multiple definitions of COIN_DBL_MAX have been removed
> >          except for the one in CoinUtils/src/CoinFinite.hpp.
> >        * The definition of COIN_DBL_MAX has been changed. Now it is a
> >          'const double' instead of a #define, and it is defined using
> >          #include<limits>.
> >                * DBL_MAX does not really conform C++ and produces
> >                  old-style cast warnings.
> >                * The use of #define is discouraged in C++, whenever
> >                  possible.
> >        * I also defined COIN_DBL_MIN in the same way and replaced DBL_MIN
> >          to this.
> >        * Similar changes have been made to COIN_INT_MAX. It became a
> >          'const int' and it is defined using #include<limits>  instead of
> >          bit operations.
> >        * The `unused parameter` warnings were resolved by removing their
> >          names from the declaration.
> >        * Finally, I weeded out all the old-style casts from the code.
> >
> > There are some warnings that still remained in the code, which I
> > couldn't fix because of my poor knowledge of Cbc internals:
> >
> >        * There are a couple of `comparison between signed and unsigned
> >          integer expressions` warnings CbcOrClpParam.cpp. (I couldn't
> >          figure out if I should convert them to `int` or `unsigned int`.)
> >        * There are a lot of `virtual function X was hidden by Y` warnings
> >          at several places. They are indeed looks quite suspicious, thus
> >          should really be investigated by someone.
> >
> > All the best,
> > Alpar
> >
> 
> 




More information about the Cbc mailing list