[Fwd: [Insight-developers] TImage::ImageDimension]
Luis Ibanez
ibanez@cs.unc.edu
Wed, 24 Jan 2001 12:16:52 -0500
This is a multi-part message in MIME format.
--------------E01DEB93293D8F0D3C4B07BF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Yinpeng,
It looks like a similar problem that we have
encounter previously.
This is a warning tha only happens in VC++,
and in spite of the warning, the code runs
correctly.
-------- Original Message --------
Subject: [Insight-developers] TImage::ImageDimension
Date: Fri, 27 Oct 2000 11:06:09 -0400
From: Luis Ibanez <ibanez@cs.unc.edu>
Reply-To: luis.ibanez@ieee.org
Organization: Medical Image Display and Analysis Group MIDAG-UNC
To: "insight-developers@public.kitware.com"
<insight-developers@public.kitware.com>
References:
<7F537688E0D6D0119A0B00805FFEBE9404660F3F@exc03crdge.crd.ge.com>
Hi,
Looking closer into the problem of using ImageDimension,
there are some funny facts:
1) In VC++ 6.0 this produce a warning, not an error
2) The warning doesn't appears with gcc, maybe
because gcc doesn't complain about zero
size arrays being declared like: int m[0];
3) In spite of the warning,...
the code runs ok with gcc and VC++.
------
This is a minimal example of the similar situation.
Here, a short "Image" class is used, just to isolate
the code from the rest of Insight, so the attached
file is self-contained.
The output of the program shows that the dimension
of the image created inside the process object is
really 3 as expected.
I will speculate that this is due to the different aspects
of the code that are checked during the several compiler
passes. Perhaps enums are initialized after array sizes
are checked....
Luis
==================================
#include <iostream>
//--------------------------------
// Image Class
//--------------------------------
template <class T, unsigned int N>
class Image {
public:
enum { ImageDimension = N };
typedef Image * Pointer;
private:
unsigned int Index[N];
};
//--------------------------------
// Process Class
//--------------------------------
template <class TImage>
class myProcess {
typedef Image<int, TImage::ImageDimension> TempImage;
typename TempImage::Pointer temp;
public:
myProcess() {
std::cout << "image dimension = ";
std::cout << TempImage::ImageDimension << std::endl;
}
};
//--------------------------------
// Main
//--------------------------------
int main()
{
typedef Image<float,3> myImageType;
myProcess<myImageType> process;
return 0;
}
--
______________________________________________________________________
Luis Ibanez
Research Assistant Professor - Division of Neurosurgery
University of North Carolina at Chapel Hill
CB# 7060, Chapel Hill, NC 27599
email : ibanez@cs.unc.edu home : http://www.cs.unc.edu/~ibanez
phone : (919)-843-9961 fax : (919)-966-6627
______________________________________________________________________
--------------E01DEB93293D8F0D3C4B07BF
Content-Type: application/x-gzip;
name="reuseImageDimension.cxx.gz"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="reuseImageDimension.cxx.gz"
H4sICD+X+TkAA3JldXNlSW1hZ2VEaW1lbnNpb24uY3h4AKVSwU6DQBS8k/APL/WiBlMTbwty
0UsPkh64GQ8r+9pssrsQWIwN6b/7doEK2qQYOb6ZefNmlitpCtUKhESWja2R6zQMwmC9vrvw
OQ5sNN8jPCneNMs0FnWluCW7wokgj6A1jdwbFCCNhYzce6Rf3YVB1b4rWbAwAEDTauh66Flq
JGVp4BEyOMYOt4cKBe4G7S1sS9qJNWFVLT/I1m+ZGW6MwM/X7I04bscfsm/rskA69D/p/aGn
yPow7ux+pUno2GgQMDZvIIWcFvtZDDBKDdf4DTA2lAHuiHhW68n3+qZ3BmisYKwoWwtJAivp
+xSTxlfxGd7U7ccbEeqpaITy0uPY98K2X7g0y8juVTWxKUwYnClyp0puo4eUYvtBTmg8qyGZ
IClU/dBTarRtbeDe/S3u+C9Wd/vLPgMAAA==
--------------E01DEB93293D8F0D3C4B07BF--