[SOLVED] Compile problem with latest 1.6 branch of ogre

al2950

21-05-2009 11:10:24

Hi

I have been getting a weird compile problem that i was unable to fix;

I am using the latest Ogre source from the 1.6 branch and it fails to compile. It works fine on the 1.6.2 tag of ogre.

I am currently at work so cant post the error at the moment but it was something todo with OgreAny.h.

Can anyone shed any light on this!??

Thanks

Angus
P.s will post compiler log when i get back home

*EDIT
COMPILER OUTPUT

1>------ Build started: Project: Caelum, Configuration: Release Win32 ------
1>Performing Pre-Build Event...
1>OGRE_HOME is G:\Ogre V1.6_Latest Branch
1>Compiling...
1>CaelumPrecompiled.cpp
1>Compiling...
1>UniversalClock.cpp
1>TypeDescriptor.cpp
1>Sun.cpp
1>SkyLight.cpp
1>SkyDome.cpp
1>PrecipitationController.cpp
1>PointStarfield.cpp
1>Moon.cpp
1>ImageStarfield.cpp
1>ImageHelper.cpp
1>GroundFog.cpp
1>GeometryFactory.cpp
1>FlatCloudLayer.cpp
1>DepthComposer.cpp
1>CloudSystem.cpp
1>CameraBoundElement.cpp
1>CaelumSystem.cpp
1>CaelumScriptTranslator.cpp
1>g:\ogre v1.6_latest branch\ogremain\include\OgreAny.h(162) : error C2593: 'operator <<' is ambiguous
1> g:\my documents\fdc ogre vis\fdc_vis\fdc_vis\caelum\include\CaelumPrerequisites.h(167): could be 'std::ostream &Ogre::operator <<(std::ostream &,Ogre::Degree)'
1> g:\ogre v1.6_latest branch\ogremain\include\OgreMath.h(131): or 'std::ostream &Ogre::operator <<(std::ostream &,const Ogre::Degree &)' [found using argument-dependent lookup]
1> while trying to match the argument list '(std::ostream, Ogre::Degree)'
1> g:\ogre v1.6_latest branch\ogremain\include\OgreAny.h(161) : while compiling class template member function 'void Ogre::Any::holder<ValueType>::writeToStream(std::ostream &)'
1> with
1> [
1> ValueType=Ogre::Degree
1> ]
1> g:\ogre v1.6_latest branch\ogremain\include\OgreAny.h(62) : see reference to class template instantiation 'Ogre::Any::holder<ValueType>' being compiled
1> with
1> [
1> ValueType=Ogre::Degree
1> ]
1> .\src\CaelumScriptTranslator.cpp(294) : see reference to function template instantiation 'Ogre::Any::Any<T>(const ValueType &)' being compiled
1> with
1> [
1> T=Ogre::Degree,
1> ValueType=Ogre::Degree
1> ]
1> .\src\CaelumScriptTranslator.cpp(327) : see reference to function template instantiation 'bool Caelum::tryHandlePropertyType<Ogre::Degree>(Ogre::ScriptCompiler *,Ogre::PropertyAbstractNode *,void *,const Caelum::ValuePropertyDescriptor *)' being compiled
1>CaelumPlugin.cpp
1>CaelumDefaultTypeDescriptorData.cpp
1>g:\ogre v1.6_latest branch\ogremain\include\OgreAny.h(162) : error C2593: 'operator <<' is ambiguous
1> g:\my documents\fdc ogre vis\fdc_vis\fdc_vis\caelum\include\CaelumPrerequisites.h(167): could be 'std::ostream &Ogre::operator <<(std::ostream &,Ogre::Degree)'
1> g:\ogre v1.6_latest branch\ogremain\include\OgreMath.h(131): or 'std::ostream &Ogre::operator <<(std::ostream &,const Ogre::Degree &)' [found using argument-dependent lookup]
1> while trying to match the argument list '(std::ostream, Ogre::Degree)'
1> g:\ogre v1.6_latest branch\ogremain\include\OgreAny.h(161) : while compiling class template member function 'void Ogre::Any::holder<ValueType>::writeToStream(std::ostream &)'
1> with
1> [
1> ValueType=Ogre::Degree
1> ]
1> g:\ogre v1.6_latest branch\ogremain\include\OgreAny.h(62) : see reference to class template instantiation 'Ogre::Any::holder<ValueType>' being compiled
1> with
1> [
1> ValueType=Ogre::Degree
1> ]
1> include\TypeDescriptor.h(136) : see reference to function template instantiation 'Ogre::Any::Any<ValueT>(const ValueType &)' being compiled
1> with
1> [
1> ValueT=Ogre::Degree,
1> ValueType=Ogre::Degree
1> ]
1> include\TypeDescriptor.h(135) : while compiling class template member function 'const Ogre::Any Caelum::TypedValuePropertyDescriptor<ValueT>::getValue(const void *) const'
1> with
1> [
1> ValueT=Ogre::Degree
1> ]
1> include\TypeDescriptor.h(156) : see reference to class template instantiation 'Caelum::TypedValuePropertyDescriptor<ValueT>' being compiled
1> with
1> [
1> ValueT=Ogre::Degree
1> ]
1> .\src\CaelumDefaultTypeDescriptorData.cpp(94) : see reference to class template instantiation 'Caelum::AccesorPropertyDescriptor<TargetT,ParamT,InParamT,OutParamT>' being compiled
1> with
1> [
1> TargetT=Caelum::CaelumSystem,
1> ParamT=Ogre::Degree,
1> InParamT=Ogre::Degree,
1> OutParamT=const Ogre::Degree
1> ]
1>Generating Code...
1>Compiling...
1>BrightStarCatalogue.cpp
1>Astronomy.cpp
1>Generating Code...
1>Build log was saved at "file://g:\My Documents\FDC Ogre Vis\FDC_VIS\FDC_Vis\Caelum\obj\release\BuildLog.htm"
1>Caelum - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

cdleonard

22-05-2009 00:21:08

Caelum uses Ogre::Degree inside Ogre::Any; and that used to fail to build because there was no operator<< for Ogre::Degree. This was fixed by declaring that operator inside Caelum. Since Ogre now added it's own operator<< for Ogre::Degree the duplicate inside CaelumPrerequisited.h has to be surrounded with #if OGRE_VERSION.

cdleonard

23-05-2009 08:48:00

There's no way to fix this instantly for the 1.6 branch because the version is still reported as 1.6.2 at compile-time. But it will work when 1.6.3 is eventually released.

It is possible to fix this without checking the ogre version but it would require a huge template mess for compatibility with a couple of unreleased ogre revisions. Here's the mess (it was fun to code):


Index: main/include/CaelumPrerequisites.h
Index: main/include/CaelumPrerequisites.h
===================================================================
--- main/include/CaelumPrerequisites.h (revision 439)
+++ main/include/CaelumPrerequisites.h (working copy)
@@ -157,7 +157,7 @@
}

namespace Ogre {
-#if OGRE_VERSION <= 0x010602
+#if OGRE_VERSION < 0x010602
// Write an Ogre::Degree to a stream.
//
// Ogre::Any requires that the wrapped type can be written to a stream;
@@ -171,6 +171,57 @@
return out << deg.valueDegrees();
}
#endif
+
+#if OGRE_VERSION >= 0x010602
+ namespace TemplateDetail
+ {
+ struct OtherType {};
+
+ // Determine if we can stream an Ogre::Degree to an ostream at compile-time.
+ struct CanStreamOgreDegree {
+ static char func(std::ostream& arg) {
+ arg << Ogre::Degree(0);
+ return 0;
+ }
+ static short func(...) {
+ return 0;
+ }
+ static const bool value = sizeof(func(std::cout)) == sizeof(char);
+ };
+
+ struct DoStreamOgreDegree {
+ static std::ostream& func(std::ostream& arg, Ogre::Degree deg) {
+ return arg << deg.valueDegrees();
+ }
+ static std::ostream& func(std::ostream& arg, OtherType x) {
+ return arg;
+ }
+ };
+
+ template<bool cond, typename ThenType, typename ElseType>
+ struct if_else_type_c { typedef ThenType type; };
+
+ template<typename ThenType, typename ElseType>
+ struct if_else_type_c<false, ThenType, ElseType> { typedef ElseType type; };
+
+ template<typename CondT, typename ThenType, typename ElseType>
+ struct if_else_type: public if_else_type_c<CondT::value, ThenType, ElseType> {};
+ }
+
+ inline std::ostream& operator<<
+ (
+ std::ostream& out,
+
+ TemplateDetail::if_else_type<
+ TemplateDetail::CanStreamOgreDegree,
+ TemplateDetail::OtherType,
+ Ogre::Degree>
+ ::type arg
+ )
+ {
+ return TemplateDetail::DoStreamOgreDegree::func(out, arg);
+ }
+#endif
}

#endif // CAELUM__CAELUM_PREREQUISITES_H

al2950

27-05-2009 17:54:42

Thanks cdleonard

I have taken a simpler approach for now and i simply commented out the code in question!

Thanks for you help

Angus

compvis

26-10-2009 08:06:15

@cdleonard: pls post full of fixed code

Thanks