Portierung Linux-> MS VC++ STLs
-
Hallo,
ich versuche die VW34 (Oxford Vision Library) von Linux nach Windows zu portieren. Anscheinend macht dabei die Verwendung von Standard Template Libraries Probleme, hier mal ein Beispiel:
vectorfixed.h(178) : error C2143: syntax error : missing ';' before '<'
1> c:\documents and settings\manuel\desktop\scenelib\vw34-edited\vnl\vectorfixed.h(197) : see reference to class template instantiation 'VNL::VectorFixed<n,T>' being compiled
vectorfixed.h(178) : error C2433: 'VNL::VectorFixed<n,T>::MatrixFixed' : 'inline' not permitted on data declarations
vectorfixed.h(178) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
vectorfixed.h(179) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
vectorfixed.h(186) : error C2143: syntax error : missing ';' before '<'
vectorfixed.h(186) : error C2433: 'VNL::VectorFixed<n,T>::MatrixFixed' : 'inline' not permitted on data declarations
vectorfixed.h(186) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
vectorfixed.h(187) : error C2334: unexpected token(s) preceding '{'; skipping apparent function bodyDa mir der Fehler leider absolut nicht klar ist hier der gesamte Quelltext:
template <int n, class T = double> class VectorFixed : public VectorFixedRef<n,T> { typedef VectorFixedRef<n,T> Base; public: /** Construct an uninitialized n-vector. */ VectorFixed():Base(space) {} /** Construct an n-vector copy of rhs. * Does not check that rhs is the right size. */ VectorFixed(Vector<T> const& rhs):Base(space) { #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) if (rhs.size() != n) ErrorVectorDimension ("VNL::VectorFixed(const VNL::Vector&) ", n, rhs.size()); #endif memcpy(space, rhs.DataBlock(), sizeof space); } /** * GCC generates (and calls) this even though above should do... */ VectorFixed(VectorFixed<n,T> const& rhs):Base(space) { memcpy(space, rhs.space, sizeof space); } /** Constructs n-vector with elements initialised to v. */ VectorFixed (T const& v): Base(space) { for (int i = 0; i < n; ++i) Base::data[i] = v; } /** Constructs 3D vector(px, py, pz ). */ VectorFixed (T const& px, T const& py, T const& pz): Base(space) { #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) if (n != 3) ErrorVectorDimension ("constructor (x,y,z): n != 3", n, 3); #endif Base::data[0] = px; Base::data[1] = py; Base::data[2] = pz; } /** Constructs 2D vector (px, py). */ VectorFixed (T const& px, T const& py): Base(space) { #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) if (n != 2) ErrorVectorDimension ("constructor (x,y): n != 2", n, 2); #endif Base::data[0] = px; Base::data[1] = py; } VectorFixed<n,T>& operator=(VectorFixed<n,T> const& rhs) { memcpy(space, rhs.space, sizeof space); return *this; } VectorFixed<n,T>& operator=(Vector<T> const& rhs) { #if VNL_CONFIG_CHECK_BOUNDS && (!defined NDEBUG) if (rhs.size() != n) ErrorVectorDimension ("operator=", n, rhs.size()); #endif memcpy(space, rhs.DataBlock(), sizeof space); return *this; } VectorFixed<n,T> Apply(T (*f)(T)) { VectorFixed<n,T> ret; VNL::CVector<T>::Apply(this->data, Base::num_elmts, f, ret.data); return ret; } VectorFixed<n,T> Apply(T (*f)(T const&)) { VectorFixed<n,T> ret; VNL::CVector<T>::Apply(this->data, Base::num_elmts, f, ret.data); return ret; } VectorFixed<n,T> operator- () const { return VectorFixed<n,T> (*this) *= -1; } VectorFixed<n,T> operator+ (T const t) const { return VectorFixed<n,T> (*this) += t; } VectorFixed<n,T> operator- (T const t) const { return VectorFixed<n,T> (*this) -= t; } VectorFixed<n,T> operator* (T const t) const { return VectorFixed<n,T> (*this) *= t; } VectorFixed<n,T> operator/ (T const t) const { return VectorFixed<n,T> (*this) /= t; } VectorFixed<n,T> operator+ (Vector<T> const& rhs) const { return VectorFixed<n,T> (*this) += rhs; } VectorFixed<n,T> operator- (Vector<T> const& rhs) const { return VectorFixed<n,T> (*this) -= rhs; } #ifdef _WIN32 friend VectorFixed<n,T> ElementProduct (VectorFixedRef<n,T> const&, VectorFixedRef<n,T> const&); friend VectorFixed<n,T> ElementQuotient (VectorFixedRef<n,T> const&, VectorFixedRef<n,T> const&); #else friend VectorFixed<n,T> ElementProduct <> (VectorFixedRef<n,T> const&, VectorFixedRef<n,T> const&); friend VectorFixed<n,T> ElementQuotient <> (VectorFixedRef<n,T> const&, VectorFixedRef<n,T> const&); #endif /**Convert a vector into a 1-by-size matrix (i.e. a row vector).*/ inline MatrixFixed<1,n,T> AsRow() { MatrixFixed<1,n,T> ret; ret.SetRow(0,*this); return ret; } /**Convert a vector into a 1-by-size matrix (i.e. a column vector).*/ inline MatrixFixed<n,1,T> AsColumn() { MatrixFixed<n,1,T> ret; ret.SetColumn(0,*this); return ret; } private: T space[n]; };
Ueber Tipps wuerde ich mich sehr freuen!
Vielen Dank auch schon fuer das Lesen,
Manuel
-
Hier die korrekten Zeilennummern, der Fehlerausgabe:
vectorfixed.h(113) : error C2143: syntax error : missing ';' before '<'
1> c:\documents and settings\manuel\desktop\scenelib\vw34-edited\vnl\vectorfixed.h(130) : see reference to class template instantiation 'VNL::VectorFixed<n,T>' being compiled
vectorfixed.h(113) : error C2433: 'VNL::VectorFixed<n,T>::MatrixFixed' : 'inline' not permitted on data declarations
vectorfixed.h(113) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
vectorfixed.h(114) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
vectorfixed.h(121) : error C2143: syntax error : missing ';' before '<'
vectorfixed.h(121) : error C2433: 'VNL::VectorFixed<n,T>::MatrixFixed' : 'inline' not permitted on data declarations
vectorfixed.h(121) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
vectorfixed.h(122) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
vectorfixed.h(113) : fatal error C1903: unable to recover from previous error(s); stopping compilation
-
Der kennt MatrixFixed zum Zeitpunkt der Verwendung nicht. Mit einer STL hat das nichts zu tun.
-
Tja, da hatte ich wohl die entscheidenden Zeilen nicht zitiert:
#ifndef _WIN32 // VC++ can't cope with forward declaring templated namespace members template <int n, class T> class VectorFixed; template<int n, int m, class T> class MatrixFixed; template <int n, class T> VectorFixed<n,T> ElementProduct(VectorFixedRef<n,T> const&, VectorFixedRef<n,T> const&); template <int n, class T> VectorFixed<n,T> ElementQuotient(VectorFixedRef<n,T>const&, VectorFixedRef<n,T> const&); //#endif
Und irgendwie kannte der Praeprozessor wohl das Makro _WIN32 nicht.
Auf jeden Fall vielen Dank!
-
Could not find a suitable section so I written here, how to become a moderator for your forum, that need for this?