Visual C++ to Borland Compiler

M

Mufe

Visual c++ compiler survives this:

#define THE_NULL -32767

struct typePair { int v2,v3; };
struct typeTriple { int v1; typePair p; };

typePair EMPTY_PAIR = {THE_NULL,THE_NULL};
typeTriple sv = {THE_NULL, EMPTY_PAIR };


Why does borland compiler return error
Cannot convert 'typePair' to 'int'
since typeTriple is defined as 2nd arg typePair.

It survives this
typeTriple sv = {THE_NULL, {THE_NULL, THE_NULL} };

Thank you
 
M

mlimber

Mufe said:
Visual c++ compiler survives this:

#define THE_NULL -32767

struct typePair { int v2,v3; };
struct typeTriple { int v1; typePair p; };

typePair EMPTY_PAIR = {THE_NULL,THE_NULL};
typeTriple sv = {THE_NULL, EMPTY_PAIR };


Why does borland compiler return error
Cannot convert 'typePair' to 'int'
since typeTriple is defined as 2nd arg typePair.

It survives this
typeTriple sv = {THE_NULL, {THE_NULL, THE_NULL} };

Thank you

I'm not sure which version of Borland C++ or Visual C++ you have, but
that code doesn't pass on my VC++ 6.0 (sp6) or Microsoft .NET 2003 (at
dinkumware.com). It does work on g++ 3.4.1, EDG (also at
dinkumware.com), and Comeau C++ (comeaucomputing.com). Since the latter
two are the most standard compliant, it seems likely that Borland is
non-conformant at that point.

BTW, in C++, it is generally preferable to use a constructor over
array-style initialization:

struct typePair
{
typePair( int a_v2, int a_v3 ) : v2( a_v2 ), v3( a_v3 ) {}
int v2,v3;
};

struct typeTriple
{
typeTriple( int a_v1, const typePair& a_p ) : v1( a_v1 ), p( a_p )
{}
int v1;
typePair p;
};

typePair EMPTY_PAIR( THE_NULL, THE_NULL );
typeTriple sv( THE_NULL, EMPTY_PAIR );

Cheers! --M
 
J

John Carson

mlimber said:
I'm not sure which version of Borland C++ or Visual C++ you have, but
that code doesn't pass on my VC++ 6.0 (sp6) or Microsoft .NET 2003 (at
dinkumware.com). It does work on g++ 3.4.1, EDG (also at
dinkumware.com), and Comeau C++ (comeaucomputing.com). Since the
latter two are the most standard compliant, it seems likely that
Borland is non-conformant at that point.

Microsoft .NET 2003 compiles it just fine for me.
 
J

John Carson

John Carson said:
Microsoft .NET 2003 compiles it just fine for me.

I am referring to an installation on my hard drive. Not some dinkumware
thing accessed over the web.
 

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
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top