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

Oliver Sander sander at mi.fu-berlin.de
Wed Jan 11 09:13:01 CET 2012


Hi Jö,
an interesting trick!  I've been thinking for quite a while how best
to get rid of these warnings.
thanks,
Oliver

Am 11.01.2012 00:44, schrieb joe at dune-project.org:
> 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




More information about the Dune mailing list