[Insight-developers] GetInverseTransform - MSVC 6 instantiation bug

Tom Vercauteren tom.vercauteren at m4x.org
Fri Apr 10 10:00:42 EDT 2009


Thanks Luis,

It would be good if we could have the correct return type because as
you mention, once it is released, the API is there "forever". However,
using TransformBase instead of Transform< T, NOutputDimensions,
NInputDimensions > might be sufficient.

It is really good to have the minimal example you wrote. Maybe we
could try posting it to some visual c++ guru forum and see if someone
comes up with a workaround. Maybe
  http://social.msdn.microsoft.com/Forums/en-US/vclanguage/threads
or
  comp.lang.c++

As a wild guess, did you try the minimal example without the
problematic typedef?

template <class T, unsigned int N, unsigned int M>
class FOO
{
public:
 typedef T  SomeTrait;
 typedef FOO<T,M,N> BAR;

 typename BAR::SomeTrait GetInverse()
   {
   BAR::SomeTrait a;
   return a;
   }
};

int main()
{
  typedef FOO<float, 3, 2>  FooType;
  FooType foo;
  FooType::BAR::SomeTrait at = foo.GetInverse();
  return 0;
}

Tom

On Fri, Apr 10, 2009 at 00:30, Luis Ibanez <luis.ibanez at kitware.com> wrote:
> Hi Bill, Tom,
>
> I tried the workaround from vnl_matrix_fixed without success.
>
> The work around seem to be indeed addressing the same case of defining
> a base class of transposed NumCols and NumRows.... so it is still likely
> that I didn't applied the workaround properly.
>
>
> In the meantime, I have replaced the return inverse type:
>
>     Transform< T, NOutputDimensions, NInputDimensions >
>
> with
>
>     TransformBase
>
> CVS commit:
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Common/itkTransform.h?root=Insight&r1=1.66&r2=1.67&sortby=date
>
> I must admit that the original type is the correct type to use here,
> so it may still be worth to further investigate the VS60 work around.
>
> In the meantime, the code should work fine with the change above.
>
>
>
> BTW: Something went wrong with the style checking of the first commit,
> but it seems that despite the problem the file was committed.
>
> I then fixed a missing space on the comment line 117 and made a second commit:
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Code/Common/itkTransform.h?root=Insight&r1=1.67&r2=1.68&sortby=date
> that curiously doesn't show any change...
> maybe because it was just a  space ?
>
>
>     Luis
>
>
> --------------------------------
> On Thu, Apr 9, 2009 at 11:04 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>> Luis,
>>
>> Look at vnl_matrix_fixed.h. They have some kind of a VS6 workaround.
>>
>> Bill
>>
>> On Thu, Apr 9, 2009 at 10:14 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>>> Hi Tom,
>>>
>>> Here is what I have found so far:
>>> The problem in VS6.0 can be replicated with the following minimal code:
>>>
>>>
>>> template <class T, unsigned int N, unsigned int M>
>>> class FOO
>>> {
>>> public:
>>>  typedef T  SomeTrait;
>>>  typedef FOO<T,M,N> BAR;
>>>  typedef typename BAR::SomeTrait  BARTrait;   // <<-----THIS
>>>
>>>  BAR GetInverse()
>>>    {
>>>    BAR a;
>>>    return a;
>>>    }
>>> };
>>>
>>>
>>> int main()
>>> {
>>>   typedef FOO<float, 3, 2>  FooType;
>>>   FooType foo;
>>>   FooType::BAR at = foo.GetInverse();
>>>   return 0;
>>> }
>>>
>>>
>>> This generates the now familiar-looking compilation error:
>>>
>>> G:\bin\TenplateRecurssion\main.cxx(10) : error C2027: use of undefined
>>> type 'FOO<float,3,2>'
>>>        G:\bin\TenplateRecurssion\main.cxx(10) : see reference to
>>> class template instantiation 'FOO<float,2,3>' being compiled
>>>        G:\bin\TenplateRecurssion\main.cxx(24) : see reference to
>>> class template instantiation 'FOO<float,3,2>' being compiled
>>> Error executing cl.exe.
>>>
>>> TenplateRecurssion.exe - 1 error(s), 0 warning(s)
>>>
>>>
>>> Note the transposition of 3,2 and 2,3.
>>>
>>> The line with the "THIS" label is the one that triggers the compilation error.
>>>
>>> As you pointed out, it seems that we are missing to use some
>>> mechanism for forcing VS6.0 to instantiate the InverseType,
>>> before we attempt to use a trait from it.
>>>
>>> ...still looking into it...
>>>
>>>
>>>
>>>   Luis
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------------
>>> On Thu, Apr 9, 2009 at 9:33 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
>>>>
>>>> Starting up my Visual Studio 6.0 compiler...
>>>>
>>>> It's going to be long morning...
>>>>
>>>>
>>>>
>>>>     Luis
>>>>
>>>>
>>>> -----------------------
>>>> Tom Vercauteren wrote:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> The dashboard is giving me the following error on visual 6 compiler:
>>>>>
>>>>> c:\Dashboards\My
>>>>> Tests\InsightContinuous\Code\Common\itkTransform.h(120) : error C2027:
>>>>> use of undefined type 'Transform<double,3,2>'
>>>>>
>>>>>        c:\Dashboards\My
>>>>> Tests\InsightContinuous\Code\Common\itkTransform.h(120) : see
>>>>> reference to class template instantiation 'itk::Transform<double,2,3>'
>>>>> being compiled
>>>>>        c:\Dashboards\My
>>>>> Tests\InsightContinuous\Code\Common\itkRigid3DPerspectiveTransform.h(42)
>>>>> : see reference to class template instantiation
>>>>> 'itk::Transform<double,3,2>' being compiled
>>>>>        c:\Dashboards\My
>>>>> Tests\InsightContinuous\Code\Common\itkTransformFactory.h(37) : see
>>>>> reference to class template instantiation
>>>>> 'itk::Rigid3DPerspectiveTransform<double>' being compiled
>>>>>        c:\Dashboards\My
>>>>> Tests\InsightContinuous\Code\Common\itkTransformFactory.h(36) : while
>>>>> compiling class-template member function 'void __cdecl
>>>>> itk::TransformFactory<class itk::Rigid3DPerspectiveTransform<double>
>>>>>
>>>>>> ::RegisterTransform(void)'
>>>>>
>>>>>
>>>>> http://www.cdash.org/CDash/viewBuildError.php?buildid=309403
>>>>>
>>>>> Can anyone help me understand what this means?
>>>>>
>>>>> I initially thought that this might be related to explicit
>>>>> instantiation since itk::Transform<double,3,2> is not listed in:
>>>>>
>>>>> http://www.itk.org/cgi-bin/viewcvs.cgi/Wrapping/ExplicitITK/Modules/Common/wrap_itkTransform.cmake?root=Insight&sortby=date&view=markup
>>>>>
>>>>> Note that I am not even sure that wrap_itkTransform.cmake is the
>>>>> correct file to look at since I have never worked with explicit
>>>>> instantiations within ITK before and since I can't manage to compile
>>>>> ITK with explicit instantiations turned on on my machine.
>>>>>
>>>>> Also it seems that dash13 is not using  explicit instantiations:
>>>>> http://www.cdash.org/CDash/testDetails.php?test=20260566&build=308626
>>>>>
>>>>> Thanks for your help.
>>>>>
>>>>> Tom
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>>>
>>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>
>>
>


More information about the Insight-developers mailing list