[vtk-developers] CLang woes with VTK5.8.0

David Partyka david.partyka at kitware.com
Fri Dec 30 11:23:55 EST 2011


Even better :-). If you don't mind can you send this to me as a patch/diff,
it makes my life a tiny bit easier when I get back to these.

http://vtk.org/Wiki/Git/Publish#Patches

On Fri, Dec 30, 2011 at 11:18 AM, kent williams
<nkwmailinglists at gmail.com>wrote:

> That ALLOC_LOCAL_ARRAY thing is clunky anyway.  The whole mess with
> the ifdefs could be replaced by a simple template class which should
> be just as efficient and more portable:
>
> template <typename TArrayElement, unsigned TSize>
> class AutoArray
> {
> public:
>  TArrayElement & operator[] (const unsigned nIndex)
>    {
>      return m_Array[nIndex];
>    }
> private:
>  TArrayElement m_Array[TSize];
> };
> #define ALLOC_LOCAL_ARRAY(name,type,n) AutoArray<type,n> name;
>
>
>
> On Fri, Dec 30, 2011 at 9:35 AM, David Partyka
> <david.partyka at kitware.com> wrote:
> > Thank you for your patch and explanation. I queued this up with all the
> > patches I hope to apply for vtk 5.8.1.
> >
> > On Fri, Dec 30, 2011 at 10:30 AM, kent williams <
> nkwmailinglists at gmail.com>
> > wrote:
> >>
> >> I've been trying to build VTK & ITK with CLang as part of another
> >> project, and run into a collision between two things CLang has a
> >> problem with:
> >>
> >> 1. vnl_math.h has a large number of warnings because of in-class
> >> definitions of static const float members.
> >> 2. vtkYoungsMaterialInterface.cxx has a macro ALLOC_LOCAL_ARRAY that
> >> uses a Gnu C extenstion to define arrays with variable length.
> >>
> >> To try and address #1, I add -Werror=gnu to the CLang compiler flags.
> >> If this is set, the compiler test for in-line static const float
> >> members fails, which gets rid of the gazillion warnings everywhere
> >> vnl_math.h is included.
> >>
> >> But this causes another problem (see #2) because
> >> vtkYoungsMaterialInterface.cxx no longer compiles, as -Werror=gnu
> >> makes all gnu extensions an error.
> >>
> >> The real problem is that CLang defines __GNUC__ -- I would think that
> >> if you make all the GNUC extensions errors, it would be a good idea of
> >> CLang no longer defined __GNUC__.
> >>
> >> Looking at the ALLOC_LOCAL_ARRAY macros, it looks like a simple patch
> >> would fix things:
> >>
> >> diff --git a/Graphics/vtkYoungsMaterialInterface.cxx
> >> b/Graphics/vtkYoungsMaterialInterface.cxx
> >> index a509a2b..407a83c 100644
> >> --- a/Graphics/vtkYoungsMaterialInterface.cxx
> >> +++ b/Graphics/vtkYoungsMaterialInterface.cxx
> >> @@ -2049,7 +2049,7 @@ namespace
> vtkYoungsMaterialInterfaceCellCutInternals
> >>   sdata += ROUND_SIZE( sizeof(type)*(n) )
> >>  #define FREE_LOCAL_ARRAY(name,type,n) sdata -= ROUND_SIZE(
> >> sizeof(type)*(n) )
> >>
> >> -#elif defined(__GNUC__) // Warning, this is a gcc extension, not all
> >> compiler accept it
> >> +#elif defined(__GNUC__) && !defined(__clang__) // Warning, this is a
> >> gcc extension, not all compiler accept it
> >>  #define ALLOC_LOCAL_ARRAY(name,type,n) type name[(n)]
> >>  #define FREE_LOCAL_ARRAY(name,type,n)
> >>  #else
> >> _______________________________________________
> >> Powered by www.kitware.com
> >>
> >> Visit other Kitware open-source projects at
> >> http://www.kitware.com/opensource/opensource.html
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.vtk.org/mailman/listinfo/vtk-developers
> >>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20111230/b2d832fe/attachment.html>


More information about the vtk-developers mailing list