namespace Validation
{
template<typename T, typename M, typename I, typename R, typename P>
void compute_metric(typename P::Pointer & imageF, typename P::Pointer &
imageM, R & region, double & value) {
typedef T TransformType;
typedef M MetricType;
typedef I InterpolatorType;
TransformType::Pointer transform = TransformType::New();
MetricType::Pointer metric = MetricType::New();
InterpolatorType::Pointer interpolator = InterpolatorType::New();
On windows vista 64 in Visual Studio this compiles fine. But in Ubuntu 9.04
I get the error:
compute_metric.h:22: error: expected `;' before 'transform'
compute_metric.h:23: error: expected `;' before 'metric'
compute_metric.h:24: error: expected `;' before 'interpolator'
corresponding to the last three lines in the above code. I have made sure
that inlcudes are setup correctly, any ideas?
I have previously experienced that various statements are allowed in VS that
is not allowed on Linux.
Those are type dependant name, shouldn't they require a 'typename'
before:
typename TransformType::Pointer transform = TransformType::New
();
typename MetricType::Pointer metric = MetricType::New();
typename InterpolatorType::Pointer interpolator = InterpolatorType::New
();
--
Michael
> In a function I have:
>
>
> namespace Validation
> {
> template<typename T, typename M, typename I, typename R, typename P>
> void compute_metric(typename P::Pointer & imageF, typename P::Pointer &
> imageM, R & region, double & value) {
> typedef T TransformType;
> typedef M MetricType;
> typedef I InterpolatorType;
>
> TransformType::Pointer transform = TransformType::New();
> MetricType::Pointer metric = MetricType::New();
> InterpolatorType::Pointer interpolator = InterpolatorType::New();
>
>
>
> On windows vista 64 in Visual Studio this compiles fine. But in Ubuntu 9.04
> I get the error:
>
> compute_metric.h:22: error: expected `;' before 'transform'
> compute_metric.h:23: error: expected `;' before 'metric'
> compute_metric.h:24: error: expected `;' before 'interpolator'
>
> corresponding to the last three lines in the above code. I have made sure
> that inlcudes are setup correctly, any ideas?
In a template definition context, it cannot be determined -- for example --
whether "TransformType::Pointer" refers to a member of the TransformType
class called "Pointer" which is an ordinary class member, or if this is a
type that's defined by the class.
You'll need to be more explicit:
class TransformType::Pointer transform = TransformType::New();
class MetricType::Pointer metric = MetricType::New();
class InterpolatorType::Pointer interpolator = InterpolatorType::New();
> I have previously experienced that various statements are allowed in VS that
> is not allowed on Linux.
gcc is much more strict on the language syntax than other compilers.
Yes I just realized that, wierd that it is allowed NOT to specify 'typename'
in VS while its mandatory in linux.
You got that wrong: it is required in c++
M$ got that wrong
Sorry to be pedentic but what you are doing is NOT cross compilation.
It is simply compiling the same code using multiple compilers. Your
subject line is rather misleading.
Yannick
It is required by VC++ since Visual Studio 2003 (dixit msdn).
And for gcc, since version 3.4 which is not all that far away (April
18, 2004 from http://gcc.gnu.org/releases.html).
--
Michael
So, you are saying the OP is using previous a compiler from previous
century.
Both 2003 and 2004 were long time ago
--
Bolje je ziveti sto godina kao bogatun, nego jedan dan kao siromah!
Or he is using compilation options that disable those checks.
> Both 2003 and 2004 were long time ago
Better than VC6 but VC6 is still in use.
--
Michael