[omniORB] omniORB2 with Borland C++ Builder app => Compilation Errors!!!

Sai-Lai Lo S.Lo@orl.co.uk
Thu, 16 Apr 1998 14:59:30 +0100


Hi David,

I gave it a go and got the omniORB2 runtime and the echo examples to
compile under Borland C++ 5.0 (I don't have the C++ builder). eg1 works.
eg2_clt seems to work with eg2_impl but eg2_impl immediately exits after
the first eg2_clt invocation. Running eg3_impl give me access violation.

I think the problem with the binaries are related to a bug I encountered
with this C++ compiler. Basically, the Borland compiler confuses enum type
with int when choosing an overloaded operator. This is illustrated with the
following examples:

wib.cc shows that Borland C++ is picking up the wrong operator>>=.

It fails to compile wob.cc because of the same confusion.

I'm going to pack up what I've done and let you have a go.
But first it is worth checking if the same bug occurs in C++ builder 3.
If it is still there then this could be a showstopper.

Regards,

Sai-Lai


--------------- wib.cc ----------------------------------
#include <iostream.h>

class S {
public:
  S() {}
  ~S() {}
};


void operator>>=(long a, S& s)
{
  cerr << "operator>>=(long a, S& s)" << endl;
}

namespace X {
  enum E { E_1, E_2 }; 
  void operator>>=(E a, S& s);
  
  class I {
  public:
    enum F { F_1, F_2 };
    friend void operator>>=(F a, S& s) {
      cerr << "operator>>=(F a, S& s)" << endl;
    }
  };
}

void X::operator>>=(X::E a, S& s)
{
  cerr << "operator>>=(E a, S& s)" << endl;
}

int
main(int,char**)
{
  long m = 1;
  X::E n = X::E_2;
  X::I::F o = X::I::F_1;
  S s;

  cerr << "Expected output:\n"
       << "   operator>>=(long a, S& s)\n"
       << "   operator>>=(E a, S& s)\n"
       << "   operator>>=(F a, S& s)" << endl;
  cerr << "\nActual output:" << endl;

  m >>= s;
  n >>= s;
  o >>= s;
  return 0;
}


---------------------------------------------------------------

------------------- wob.cc ------------------------------------
#include <iostream.h>

class S {
public:
  S() {}
  ~S() {}
};


void operator>>=(long a, S& s)
{
  cerr << "operator>>=(long a, S& s)" << endl;
}

namespace X {
  enum E { E_1, E_2 }; 
  void operator>>=(E a, S& s);
  
  class I {
  public:
    enum F { F_1, F_2 };
    friend void operator>>=(F a, S& s) {
      cerr << "operator>>=(F a, S& s)" << endl;
    }
    static void f();
  };
}

void X::operator>>=(X::E a, S& s)
{
  cerr << "operator>>=(E a, S& s)" << endl;
}

void 
X::I::f()
{
  long m = 1;
  X::E n = X::E_2;
  X::I::F o = X::I::F_1;
  S s;

  cerr << "Expected output:\n"
       << "   operator>>=(long a, S& s)\n"
       << "   operator>>=(E a, S& s)\n"
       << "   operator>>=(F a, S& s)" << endl;
  cerr << "\nActual output:" << endl;

  m >>= s;
  n >>= s;
  o >>= s;
}

int
main(int,char**)
{
  X::I::f();
  return 0;
}
------------------------------------------------------------------