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

Oliver Sander sander at mi.fu-berlin.de
Wed Jan 11 12:27:32 CET 2012


>>
>> 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.

Yes.  That is how we got into this discussion in the first place.

>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...

I agree that this would be best.  And likely it is not even all that 
difficult,
since you can copy'n'paste most of dune_deprecated.m4.

best,
Oliver

>
> 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
>
>




More information about the Dune mailing list