Text 5532, 273 rader
Skriven 2006-03-20 21:55:00 av Paul Rogers (1:105/360.0)
Ärende: c++ help needed
=======================
I don't speak c++. My mother tongue was FORTRAN-II ferchrissakes!
I need help.
I've been building a new LFS-6.1 system. Compared to my LFS-4.1, it
upgrades the compiler from 3.2.1 to 3.4.3. I'm trying to compile
KDE-3.1, but keep running into errors. (It worked with GCC-3.2.1!) So
far most have been extraneous semicolons after some braces. I've been
removing them as the new compiler insisted, thinking I could then
generate a proper patch set, not available at kde.org. Then I got this:
**************
Making all in .
make[3]: Entering directory `/usr/local/src/lfs-6.1/pallas/kdelibs-3.1/kdecore'
/bin/sh ../libtool --silent --mode=compile --tag=CXX g++ -DHAVE_CONFIG_H -I. \
-I. -I.. -I../kdefx -I../dcop -I../libltdl -I../kdecore -I../kdeui -I../kio \
-I../kio/kio -I../kio/kfile -I.. -I/usr/local/qt/include -I/usr/X11R6/include \
-I/usr/local/kde-3.1/include -I/usr/local/include/libart-2.0 \
-DQT_THREAD_SUPPORT -D_REENTRANT -Wnon-virtual-dtor -Wno-long-long -Wundef \
-Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi \
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -DNDEBUG \
-DNO_DEBUG -O2 -fno-exceptions -fno-check-new -DQT_NO_TRANSLATION \
-DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_COMPAT -c -o kcompletion.lo \
`test -f 'kcompletion.cpp' || echo './'`kcompletion.cpp
cc1plus: warning: command line option "-Wmissing-prototypes" is valid for C/Ob
jC but not for C++
In file included from kcompletion.h:31,
from kcompletion.cpp:27:
./ksortablevaluelist.h: In member function `KSortableItem<T, Key>& KSortableIt
em<T, Key>::operator=(const KSortableItem<T, Key>&)':
./ksortablevaluelist.h:56: error: `first' undeclared (first use this function)
./ksortablevaluelist.h:56: error: (Each undeclared identifier is reported only
once for each function it appears in.)
./ksortablevaluelist.h:57: error: `second' undeclared (first use this function)
./ksortablevaluelist.h: In member function `bool KSortableItem<T, Key>::operato
r>(const KSortableItem<T, Key>&) const':
./ksortablevaluelist.h:67: error: `first' undeclared (first use this function)
./ksortablevaluelist.h: In member function `bool KSortableItem<T, Key>::operato
r<(const KSortableItem<T, Key>&) const':
./ksortablevaluelist.h:74: error: `first' undeclared (first use this function)
./ksortablevaluelist.h: In member function `bool KSortableItem<T, Key>::operato
r>=(const KSortableItem<T, Key>&) const':
./ksortablevaluelist.h:81: error: `first' undeclared (first use this function)
./ksortablevaluelist.h: In member function `bool KSortableItem<T, Key>::operato
r<=(const KSortableItem<T, Key>&) const':
./ksortablevaluelist.h:88: error: `first' undeclared (first use this function)
./ksortablevaluelist.h: In member function `bool KSortableItem<T, Key>::operato
r==(const KSortableItem<T, Key>&) const':
./ksortablevaluelist.h:95: error: `first' undeclared (first use this function)
./ksortablevaluelist.h: In member function `bool KSortableItem<T, Key>::operato
r!=(const KSortableItem<T, Key>&) const':
./ksortablevaluelist.h:102: error: `first' undeclared (first use this function)
./ksortablevaluelist.h: In member function `T& KSortableItem<T, Key>::value()':
./ksortablevaluelist.h:110: error: `second' undeclared (first use this
function)
./ksortablevaluelist.h: In member function `const T& KSortableItem<T, Key>::val
ue() const':
./ksortablevaluelist.h:117: error: `second' undeclared (first use this
function)
./ksortablevaluelist.h: In member function `Key KSortableItem<T, Key>::index()
const':
./ksortablevaluelist.h:125: error: `first' undeclared (first use this function)
make[3]: *** [kcompletion.lo] Error 1
make[3]: Leaving directory `/usr/local/src/lfs-6.1/pallas/kdelibs-3.1/kdecore'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/lfs-6.1/pallas/kdelibs-3.1/kdecore'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/lfs-6.1/pallas/kdelibs-3.1'
make: *** [all] Error 2
**************
Here's ksortablevaluelist.h:
**************
/* This file is part of the KDE libraries
Copyright (C) 2001 Carsten Pfeiffer <pfeiffer@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KSORTABLEVALUELIST_H
#define KSORTABLEVALUELIST_H
#include <qpair.h>
#include <qvaluelist.h>
/**
* KSortableItem is a @ref QPair that provides several operators
* for sorting.
* @see KSortableValueList
*/
template<class T, class Key = int> class KSortableItem : public QPair<Key,T>
{
public:
/**
* Creates a new KSortableItem with the given values.
* @param i the first value
* @param t the second value
*/
KSortableItem( Key i, const T& t ) : QPair<Key, T>( i, t ) {}
/**
* Creates a new KSortableItem that copies another one.
* @param rhs the other item to copy
*/
KSortableItem( const KSortableItem<T, Key> &rhs )
: QPair<Key,T>( rhs.first, rhs.second ) {}
/**
* Creates a new KSortableItem with uninitialized values.
*/
KSortableItem() {}
/**
* Assignment operator, just copies the item.
*/
KSortableItem<T, Key> &operator=( const KSortableItem<T, Key>& i ) {
first = i.first;
second = i.second;
return *this;
}
// operators for sorting
/**
* Compares the two items. This implementation only compares
* the first value.
*/
bool operator> ( const KSortableItem<T, Key>& i2 ) const {
return (i2.first < first);
}
/**
* Compares the two items. This implementation only compares
* the first value.
*/
bool operator< ( const KSortableItem<T, Key>& i2 ) const {
return (first < i2.first);
}
/**
* Compares the two items. This implementation only compares
* the first value.
*/
bool operator>= ( const KSortableItem<T, Key>& i2 ) const {
return (first >= i2.first);
}
/**
* Compares the two items. This implementation only compares
* the first value.
*/
bool operator<= ( const KSortableItem<T, Key>& i2 ) const {
return !(i2.first < first);
}
/**
* Compares the two items. This implementation only compares
* the first value.
*/
bool operator== ( const KSortableItem<T, Key>& i2 ) const {
return (first == i2.first);
}
/**
* Compares the two items. This implementation only compares
* the first value.
*/
bool operator!= ( const KSortableItem<T, Key>& i2 ) const {
return (first != i2.first);
}
/**
* Returns the second value.
* @return the second value
*/
T& value() {
return second;
}
/**
* Returns the second value.
*/
const T& value() const {
return second;
}
/**
* Returns the first value.
* @param the first value
*/
Key index() const {
return first;
}
};
/**
* KSortableValueList is a special @ref QValueList for
* @ref KSortableItem. It includes convenience operators
* to get the first value of the KSortableItem and a method
* to sort all items.
*/
template <class T, class Key = int>
class KSortableValueList : public QValueList<KSortableItem<T, Key> >
{
public:
/**
* Insert a KSortableItem with the given values.
* @param i the first value
* @param t the second value
*/
void insert( Key i, const T& t ) {
QValueList<KSortableItem<T, Key> >::append( KSortableItem<T, Key>( i, t
) );
}
// add more as you please...
/**
* Returns the first value of the KSortableItem at the given position.
* @return the first value of the KSortableItem
*/
T& operator[]( Key i ) {
return QValueList<KSortableItem<T, Key> >::operator[]( i ).value();
}
/**
* Returns the first value of the KSortableItem at the given position.
* @return the first value of the KSortableItem
*/
const T& operator[]( Key i ) const {
return QValueList<KSortableItem<T, Key> >::operator[]( i ).value();
}
/**
* Sorts the KSortableItems.
*/
void sort() {
qHeapSort( *this );
}
};
// template <class T> class KSortableValueListIterator : public
QValueListIterator<KSortableItem<T> >
// {
// };
#endif // KSORTABLEVALUELIST_H
**************
Knowing nothing about c++, but having done a few over the years, I'm
guessing GCC-3.4.3 changed the acceptable way of referencing an array?
It may just postpone the inevitable, but what's the correct syntax? i.1?
Is there a compatibility option perhaps? Can the compiler be persuaded?
(To upgrade to a newer version of KDE, I'd also have to upgrade QT, and
no doubt other dependencies. Newer versions, more "features", more
code, slower; I'd like to avoid that. I suppose it's possible to
install the GCC-3.2.1 to compile KDE, but that's not something I feel
confident about.)
Paul Rogers, paulgrogers@yahoo.com -o)
http://www.angelfire.com/or/paulrogers /\\
Rogers' Second Law: Everything you do communicates. _\_V
... Real programmers can write FORTRAN in ANY language.
___ MultiMail/MS-DOS v0.35
---
* Origin: The Bare Bones BBS (1:105/360)
|