0

I'm trying to port OpenCV to C++ Builder (XE3 version).

I've encountered many compiler errors.

As I know, BCC 32-bit is not a clang complaint compiler, and does not follow C++11 standards. This is why I have met with so many issues.

I tried to resolve parts of these issues one by one with workarounds. However, I cannot resolve the following one. Can someone help me about this?

p.s. I know it is an issue with BCC32, as this code can be compiled successfully with Visual Studio, or even BCC64 compiler.

The following code is extracted from ImfBoxAttribute.cpp (in opencv 2.4.11\sources\3rdparty\openexr\IlmImf)

template <>
void
Box2iAttribute::writeValueTo (OStream &os, int) const
{
    Xdr::write <StreamIO> (os, _value.min.x);
    Xdr::write <StreamIO> (os, _value.min.y);
    Xdr::write <StreamIO> (os, _value.max.x);
    Xdr::write <StreamIO> (os, _value.max.y);
}

When I compile with C++ Builder XE3 32bit, I meet with the following compiler errors:

[bcc32 Error] ImfBoxAttribute.cpp(61): E2171 Body has already been defined for function 'Box2iAttribute::writeValueTo(OStream &,int) const'

and

[bcc32 Error] ImfBoxAttribute.cpp(62): E2451 Undefined symbol 'os'
  Full parser context
    ImfBoxAttribute.cpp(47): namespace Imf
    ImfBoxAttribute.cpp(61): parsing: void Box2iAttribute::writeValueTo(OStream &,int) const

Here is the definition of Box2iAttribute:

typedef TypedAttribute<Imath::Box2i> Box2iAttribute;
typedef Box <V2i> Box2i;
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Ducky Chen
  • 369
  • 2
  • 5

1 Answers1

0

I don't see how this is valid code, in any pre-C++11 compiler. You are trying to define a template specialized implementation for Box2iAttribute::writeValueTo(), but Box2iAttribute is just an alias for TypedAttribute<Imath::Box2i> and cannot be used to qualify an implementation like you are attempting. And where is the template parameter that you are trying to specialize? It is not attached to Box2iAttribute, it would have to be attached to writeValueTo() instead. But where is the specialization actually declared? And the fact that the compiler is complaining about an existing body means that a TypedAttribute<Imath::Box2i>::writeValueTo() implementation has already been defined, so you cannot define a new one.

Maybe C++11 allows this weird code, which would explain VS and BCC64 accepting it. But you are certainly not going to get BCC32 to accept it. If you want help porting this code to BCC32, or any other pre-C++11 compiler, you need to show a more complete example demonstrating exactly what you are trying to accomplish. What you have shown is not complete. Please don't ask people to go download external libraries just to see the code. Post the relevant pieces here, or create a MCVE demonstrating the same concepts.

Community
  • 1
  • 1
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770