[Dune] [Dune-Commit] dune-grid r7830 - trunk/dune/grid/uggrid

Andreas Lauser andreas.lauser at iws.uni-stuttgart.de
Wed Jan 11 11:24:49 CET 2012


Hi,

On Mittwoch, 11. Januar 2012 you wrote:
> On second thoughts, why does the variable I write to have to be a member
> of a base class?  Just to avoid name conflicts?  It seems overly
> complicated to add an extra base class for UG_NS just to get a static
> variable.
> 
> I am not sure we need this in dune-common.  Most set-but-unused warnings
> can probably be fixed, instead of needing a workaround.

in some ugly cases (like UGGrid) that's not really possible because a macro 
requires a variable name as an argument. the clean solution would be to mark 
the variable with __attribute__((unused)). Though this would require an 
autoconf test and hiding the attribute behind a macro DUNE_UNUSED. Since I've 
recently banged head against the wall because of the autotools more often than 
I'd like to, I won't implement this...

cheers
  Andreas

> Am 11.01.2012 09:48, schrieb Christian Engwer:
> > Hi Jö,
> > 
> > seems like this is trick that might come handy in many places. Perhaps
> > we should move it dune-common?
> > 
> > Christian
> > 
> > On Wed, Jan 11, 2012 at 12:44:15AM +0100, joe at dune-project.org wrote:
> >> Author: joe
> >> Date: 2012-01-11 00:44:14 +0100 (Wed, 11 Jan 2012)
> >> New Revision: 7830
> >> 
> >> Modified:
> >>     trunk/dune/grid/uggrid/uggrid.cc
> >>     trunk/dune/grid/uggrid/ugwrapper.hh
> >> 
> >> Log:
> >> [UGGrid] Fix warnings about unused variables.
> >> 
> >> Modified: trunk/dune/grid/uggrid/uggrid.cc
> >> ===================================================================
> >> --- trunk/dune/grid/uggrid/uggrid.cc	2012-01-10 23:44:10 UTC (rev 
7829)
> >> +++ trunk/dune/grid/uggrid/uggrid.cc	2012-01-10 23:44:14 UTC (rev 7830)
> >> @@ -21,6 +21,8 @@
> >> 
> >>   //
> >>   //********************************************************************
> >>   ***
> >> 
> >> +const UG_NS_Base::IgnoreType UG_NS_Base::ignore =
> >> UG_NS_Base::IgnoreType(); +
> >> 
> >>   template<>  int Dune::UGGrid<2>::numOfUGGrids = 0;
> >>   template<>  int Dune::UGGrid<3>::numOfUGGrids = 0;
> >> 
> >> Modified: trunk/dune/grid/uggrid/ugwrapper.hh
> >> ===================================================================
> >> --- trunk/dune/grid/uggrid/ugwrapper.hh	2012-01-10 23:44:10 UTC (rev
> >> 7829) +++ trunk/dune/grid/uggrid/ugwrapper.hh	2012-01-10 23:44:14 UTC
> >> (rev 7830) @@ -7,6 +7,17 @@
> >> 
> >>   namespace Dune {
> >> 
> >> +#if UG_DIM == 2
> >> +  /* Define stuff that is needed by the UG wrapper */
> >> +  struct UG_NS_Base {
> >> +    // class to ignore assigned values
> >> +    // avoids unused-variable warnings by the compiler (which you may
> >> run into +    // when using a dummy variable)
> >> +    struct IgnoreType { template<class T>  void operator=(const T&)
> >> const { } }; +    static const IgnoreType ignore;
> >> +  };
> >> +#endif
> >> +
> >> 
> >>       /** \brief Encapsulates a few UG methods and macros
> >>       
> >>        *
> >>        * This class provides a wrapper to several methods and macros
> >>        from
> >> 
> >> @@ -22,7 +33,7 @@
> >> 
> >>   #endif
> >>   
> >>   template<>
> >> 
> >> -class UG_NS<  UG_DIM>  {
> >> +class UG_NS<  UG_DIM>  : public UG_NS_Base {
> >> 
> >>   public:
> >>       // //////////////////////////////////////////////
> >> 
> >> @@ -383,8 +394,7 @@
> >> 
> >>           using UG_NAMESPACE ::PRISM;
> >>           using UG_NAMESPACE ::n_offset;
> >>           using UG::UINT;
> >> 
> >> -        int n;  // Dummy variable just to please the macro
> >> -        CORNER_COORDINATES(theElement, n, x);
> >> +        CORNER_COORDINATES(theElement, ignore, x);
> >> 
> >>       }
> >>       
> >>       /** \brief Returns pointers to the coordinate arrays of an UG node
> >>       */
> >> 
> >> _______________________________________________
> >> Dune-Commit mailing list
> >> Dune-Commit at dune-project.org
> >> http://lists.dune-project.org/mailman/listinfo/dune-commit
> > 
> > _______________________________________________
> > Dune mailing list
> > Dune at dune-project.org
> > http://lists.dune-project.org/mailman/listinfo/dune
> 
> _______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune


-- 
Andreas Lauser
Department of Hydromechanics and Modelling of Hydrosystems
University of Stuttgart
Pfaffenwaldring 61
D-70569 Stuttgart
Phone: (+49) 711 685-64719
Fax: (+49) 711 685-60430
www.hydrosys.uni-stuttgart.de




More information about the Dune mailing list