This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
compile errors
- From: Guohua Ma <maguohua at hpc dot me dot utexas dot edu>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 28 Feb 2003 12:27:34 -0600 (CST)
- Subject: compile errors
dear sir:
I met some compiling problems when i use gcc3.2 to compile my program. my
system is:
redhat 8.0
qt3-gcc3.2
gcc 3.2
can you help me to fix it? followings are error messages and source code.
error messages:
g++ -g -I.. -I/usr/lib/qt3-gcc3.2/include -c -o PointerSwizzler.o
PointerSwizzler.C
In file included from PointerSwizzler.C:1:
../util/PointerSwizzler.H:12: parse error before `*' token
../util/PointerSwizzler.H:13: parse error before `*' token
../util/PointerSwizzler.H:14: ISO C++ forbids declaration of `type_info'
with
no type
../util/PointerSwizzler.H:14: parse error before `*' token
../util/PointerSwizzler.H:15: parse error before `*' token
../util/PointerSwizzler.H:20: ISO C++ forbids declaration of `type name'
with
no type
../util/PointerSwizzler.H:20: parse error before `*' token
../util/PointerSwizzler.H:23: `KeyType' was not declared in this scope
../util/PointerSwizzler.H:23: parse error before `,' token
../util/PointerSwizzler.H:34: ISO C++ forbids declaration of `type name'
with
no type
../util/PointerSwizzler.H:34: parse error before `<' token
../util/PointerSwizzler.H:35: `pair' was not declared in this scope
../util/PointerSwizzler.H:35: parse error before `*' token
../util/PointerSwizzler.H:38: ISO C++ forbids declaration of `MapType'
with no
type
../util/PointerSwizzler.H:38: parse error before `;' token
../util/PointerSwizzler.H: In member function `bool
PointerSwizzler::ltptr::operator()(...) const':
../util/PointerSwizzler.H:29: `a' undeclared (first use this function)
../util/PointerSwizzler.H:29: (Each undeclared identifier is reported only
once
for each function it appears in.)
../util/PointerSwizzler.H:29: `b' undeclared (first use this function)
../util/PointerSwizzler.H: In function `long unsigned int
swizzle_pointer(T*)':
../util/PointerSwizzler.H:45: ISO C++ forbids declaration of `type_info'
with
no type
../util/PointerSwizzler.H:45: parse error before `*' token
../util/PointerSwizzler.H: In function `long unsigned int
get_swizzle(T*)':
../util/PointerSwizzler.H:52: ISO C++ forbids declaration of `type_info'
with
no type
../util/PointerSwizzler.H:52: parse error before `*' token
../util/PointerSwizzler.H: At global scope:
../util/PointerSwizzler.H:56: syntax error before `*' token
PointerSwizzler.C:4: syntax error before `::' token
PointerSwizzler.C:16: parse error before `*' token
PointerSwizzler.C: In static member function `static long unsigned int
PointerSwizzler::insert(...)':
PointerSwizzler.C:18: `KeyType' undeclared (first use this function)
PointerSwizzler.C:18: parse error before `(' token
PointerSwizzler.C:19: `MapType' undeclared (first use this function)
PointerSwizzler.C:20: `match' undeclared (first use this function)
PointerSwizzler.C:20: `key' undeclared (first use this function)
PointerSwizzler.C:23: `s_swizzler' undeclared (first use this function)
PointerSwizzler.C:23: `ValueType' undeclared (first use this function)
PointerSwizzler.C: At global scope:
PointerSwizzler.C:31: parse error before `*' token
PointerSwizzler.C: In member function `long unsigned int
PointerSwizzler::operator()(...) const':
PointerSwizzler.C:33: parse error before `(' token
PointerSwizzler.C: At global scope:
PointerSwizzler.C:42: parse error before `*' token
PointerSwizzler.C: In static member function `static long unsigned int
PointerSwizzler::find(...)':
PointerSwizzler.C:44: parse error before `(' token
PointerSwizzler.C: At global scope:
PointerSwizzler.C:52: syntax error before `*' token
PointerSwizzler.C:55: syntax error before `::' token
make: *** [PointerSwizzler.o] Error 1
my source code is: //PointerSwizzler.H
#ifndef PointerSwizzler_H
#define PointerSwizzler_H
#include <typeinfo>
#include <map>
class PointerSwizzler {
public:
PointerSwizzler() ;
~PointerSwizzler() ;
static unsigned long insert( void*, const type_info* ) ;
static unsigned long find( void*, const type_info* ) ;
static const type_info* find_type( void* ) ;
unsigned long operator() ( void*, const type_info* ) const ;
static void reset() ;
protected:
typedef pair<void*,const type_info*> KeyType ;
struct ltptr {
bool operator ()( KeyType a, KeyType b ) const
{
#if 0
return ( (a.first < b.first) ||
(a.first == b.first && a.second->before( *(b.second) ) ) )
;
#else
return ( a.first < b.first ) ;
#endif
}
} ;
typedef pair< const pair<void*,const type_info*>, unsigned long>
ValueType ;
typedef map< pair<void*,const type_info*>, unsigned long, ltptr >
MapType ;
static MapType s_swizzler ;
static unsigned long s_current ;
} ;
template<class T>
unsigned long swizzle_pointer( T* pointer )
{
const type_info* classid = &typeid( pointer ) ;
return PointerSwizzler::insert( reinterpret_cast<void*>(pointer),
classid ) ;
}
template<class T>
unsigned long get_swizzle( T* pointer )
{
const type_info* classid = &typeid( pointer ) ;
return PointerSwizzler::find( reinterpret_cast<void*>(pointer), classid
) ;
}
inline const type_info* find_type( void* pointer )
{ return PointerSwizzler::find_type( pointer ) ; }
inline void reset_swizzler() { PointerSwizzler::reset() ; }
#endif // PointerSwizzler_H
I searched through internet, however i couldnot fix it. could you help me
to fix it?
guohua