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.<div><br></div><div><a href="http://vtk.org/Wiki/Git/Publish#Patches">http://vtk.org/Wiki/Git/Publish#Patches</a> <br>

<br><div class="gmail_quote">On Fri, Dec 30, 2011 at 11:18 AM, kent williams <span dir="ltr"><<a href="mailto:nkwmailinglists@gmail.com">nkwmailinglists@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

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