Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cross Compilation of C++ Code?

0 views
Skip to first unread message

fdm

unread,
Sep 30, 2009, 6:39:52 AM9/30/09
to
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.

Michael Doubez

unread,
Sep 30, 2009, 7:08:00 AM9/30/09
to
On 30 sep, 12:39, "fdm" <f...@gk.com> wrote:
> 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
();

--
Michael

Sam

unread,
Sep 30, 2009, 7:09:42 AM9/30/09
to
fdm writes:

> 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.

fdm

unread,
Sep 30, 2009, 7:09:55 AM9/30/09
to

"Michael Doubez" <michael...@free.fr> wrote in message
news:d25e98ad-2ab6-41aa...@k19g2000yqc.googlegroups.com...

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

Vladimir Jovic

unread,
Sep 30, 2009, 7:14:57 AM9/30/09
to

You got that wrong: it is required in c++
M$ got that wrong

Yannick Tremblay

unread,
Sep 30, 2009, 7:54:02 AM9/30/09
to

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

Michael Doubez

unread,
Sep 30, 2009, 8:34:35 AM9/30/09
to
On 30 sep, 13:14, Vladimir Jovic <vladasp...@gmail.com> wrote:
> fdm wrote:
>
> > "Michael Doubez" <michael.dou...@free.fr> wrote in message

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

Vladimir Jovic

unread,
Sep 30, 2009, 9:20:29 AM9/30/09
to

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!

Michael Doubez

unread,
Sep 30, 2009, 10:07:11 AM9/30/09
to
On 30 sep, 15:20, Vladimir Jovic <vladasp...@gmail.com> wrote:
> Michael Doubez wrote:
> > On 30 sep, 13:14, Vladimir Jovic <vladasp...@gmail.com> wrote:
> >> You got that wrong: it is required in c++
> >> M$ got that wrong
>
> > 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 fromhttp://gcc.gnu.org/releases.html).

>
> 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.

--
Michael

0 new messages