Cross Compilation of C++ Code?

F

fdm

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?

I have previously experienced that various statements are allowed in VS that
is not allowed on Linux.
 
M

Michael Doubez

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();

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
();
 
F

fdm

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();

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
();



Yes I just realized that, wierd that it is allowed NOT to specify 'typename'
in VS while its mandatory in linux.
 
V

Vladimir Jovic

fdm said:
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
();



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
 
V

Vladimir Jovic

Michael said:
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).

So, you are saying the OP is using previous a compiler from previous
century.
Both 2003 and 2004 were long time ago
 
M

Michael Doubez

So, you are saying the OP is using previous a compiler from previous
century.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top