Game Development Community

Gcc 3.4.x compile errors

by Benoit Touchette · in RTS Starter Kit · 11/26/2004 (7:02 pm) · 3 replies

I am getting the following errors with the 1.0 Linux installer with gcc 3.4.x:

Quote:
In file included from ./audio/audioBuffer.h:16,
from ./audio/audioDataBlock.h:13,
from audio/audio.cc:7:
./core/resManager.h: In member function 'void Resource::unlock()':
./core/resManager.h:255: error: invalid use of undefined type 'struct ResManager'
./core/resManager.h:38: error: forward declaration of 'struct ResManager'
./core/resManager.h: In member function 'void Resource::purge()':
./core/resManager.h:263: error: invalid use of undefined type 'struct ResManager'
./core/resManager.h:38: error: forward declaration of 'struct ResManager'
./core/resManager.h:265: error: invalid use of undefined type 'struct ResManager'
./core/resManager.h:38: error: forward declaration of 'struct ResManager'
./core/resManager.h: In member function 'void Resource::_unlock()':
./core/resManager.h:278: error: invalid use of undefined type 'struct ResManager'
./core/resManager.h:38: error: forward declaration of 'struct ResManager'
In file included from ./sim/netConnection.h:19,
from ./game/gameConnection.h:16,
from audio/audio.cc:11:
./platform/event.h: At global scope:
./platform/event.h:137: error: a casts to a type other than an integral or enumeration type cannot appear in a constant-expression
./platform/event.h:137: error: '->' cannot appear in a constant-expression
./platform/event.h:137: error: '&' cannot appear in a constant-expression
./platform/event.h:137: error: enumerator value for 'PacketReceiveEventHeaderSize' not integer constant
./platform/event.h:140: error: a casts to a type other than an integral or enumeration type cannot appear in a constant-expression
./platform/event.h:140: error: '->' cannot appear in a constant-expression
./platform/event.h:140: error: '&' cannot appear in a constant-expression
./platform/event.h:140: error: enumerator value for 'ConnectedReceiveEventHeaderSize' not integer constant
./platform/event.h:143: error: a casts to a type other than an integral or enumeration type cannot appear in a constant-expression
./platform/event.h:143: error: '->' cannot appear in a constant-expression
./platform/event.h:143: error: '&' cannot appear in a constant-expression
./platform/event.h:145: error: enumerator value for 'ConsoleEventHeaderSize' not integer constant

Using the information as discussed in this www.garagegames.com/mg/forums/result.thread.php?qt=21521 thread should fix the issue. Here is a patch:

#1
11/26/2004 (7:03 pm)
diff -ur torque_rts-1.0.org/engine/platform/event.h torque_rts-1.0/engine/platform/event.h
--- torque_rts-1.0.org/engine/platform/event.h  2004-11-26 23:17:54.739012960 -0500
+++ torque_rts-1.0/engine/platform/event.h      2004-11-26 23:25:03.508830040 -0500
@@ -133,6 +133,16 @@
 /// Header sizes for events defined later on.
 enum HeaderSizes
 {
+#if defined(TORQUE_COMPILER_GCC) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))
+   /// Byte offset to payload of a PacketReceiveEvent
+   PacketReceiveEventHeaderSize = sizeof(PacketReceiveEvent) - MaxPacketDataSize,
+
+   /// Byte offset to payload of a ConnectedReceiveEvent
+   ConnectedReceiveEventHeaderSize = sizeof(ConnectedReceiveEvent) - MaxPacketDataSize,
+
+   /// Byte offset to payload of a ConsoleEvent
+   ConsoleEventHeaderSize = sizeof(ConsoleEvent) - MaxConsoleLineSize
+#else
    /// Byte offset to payload of a PacketReceiveEvent
    PacketReceiveEventHeaderSize = Offset(data,PacketReceiveEvent),

@@ -141,7 +151,7 @@

    /// Byte offset to payload of a ConsoleEvent
    ConsoleEventHeaderSize = Offset(data,ConsoleEvent)
-
+#endif
 };
#2
11/26/2004 (7:05 pm)
Splice the next two together to get the patch file as this forum system only accpets 4096 byte sized messages.

diff -ur torque_rts-1.0.org/engine/core/resManager.h torque_rts-1.0/engine/core/resManager.h
--- torque_rts-1.0.org/engine/core/resManager.h 2004-11-26 23:17:54.386066616 -0500
+++ torque_rts-1.0/engine/core/resManager.h     2004-11-26 23:25:40.712174272 -0500
@@ -194,90 +194,6 @@
 }


-//------------------------------------------------------------------------------
-/// Wrapper class around a ResourceInstance subclass.
-///
-/// @code
-///    // Loading a resource...
-///    Resource<TerrainFile> terrRes;
-///
-///    terrRes = ResourceManager->load(fileName);
-///    if(!bool(terrRes))
-///       Con::errorf(ConsoleLogEntry::General, "Terraformer::terrainFile - invalid terrain file '%s'.", fileName);
-/// @endcode
-///
-/// When the Resource<> is destroyed, it frees the lock on the resource.
-///
-/// @see ResManager
-template <class T> class Resource
-{
-private:
-   ResourceObject *obj;  ///< Actual resource object
-
-   // ***WARNING***
-   // Using a faster lock that bypasses the resource manger.
-   // void _lock() { if (obj) obj->rm->lockResource( obj ); }
-   void _lock();   ///< Increments the lock count on this object
-   void _unlock(); ///< Decrements the lock count on this object
-
-public:
-   /// If assigned a ResourceObject, it's assumed to already have
-   /// been locked, lock count is incremented only for copies or
-   /// assignment from another Resource.
-   Resource() : obj(NULL) { ; }
-   Resource(ResourceObject *p) : obj(p) { ; }
-   Resource(const Resource &res) : obj(res.obj) { _lock(); }
-   ~Resource() { unlock(); }  ///< Decrements the lock count on this object, and if the lock count is 0 afterwards,
-                              ///< adds the object to the timeoutList for deletion on execution of purge().
-
-   const char *getFilePath() const { return (obj ? obj->path : NULL); } ///< Returns the path of the file (without the actual name)
-   const char *getFileName() const { return (obj ? obj->name : NULL); } ///< Returns the actual file name (without the path)
-
-   Resource& operator= (ResourceObject *p) { _unlock(); obj = p; return *this; }
-   Resource& operator= (const Resource &r) { _unlock(); obj = r.obj; _lock(); return *this; }
-
-   U32 getCRC() { return (obj ? obj->crc : 0); }
-   bool isNull()   const { return ((obj == NULL) || (obj->mInstance == NULL)); }
-   operator bool() const { return ((obj != NULL) && (obj->mInstance != NULL)); }
-   T* operator->()   { return (T*)obj->mInstance; }
-   T& operator*()    { return *((T*)obj->mInstance); }
-   operator T*() const    { return (obj) ? (T*)obj->mInstance : (T*)NULL; }
-   const T* operator->() const  { return (const T*)obj->mInstance; }
-   const T& operator*() const   { return *((const T*)obj->mInstance); }
-   operator const T*() const    { return (obj) ? (const T*)obj->mInstance :  (const T*)NULL; }
-   void unlock();
-   void purge();
-};
-
-template<class T> inline void Resource<T>::unlock()
-{
-   if (obj) {
-      ResourceManager->unlock( obj );
-      obj=NULL;
-   }
-}
-
-template<class T> inline void Resource<T>::purge()
-{
-   if (obj) {
-      ResourceManager->unlock( obj );
-      if (obj->lockCount == 0)
-         ResourceManager->purge(obj);
-      obj = NULL;
-   }
-}
-template <class T> inline void Resource<T>::_lock()
-{
-   if (obj)
-      obj->lockCount++;
-}
-
-template <class T> inline void Resource<T>::_unlock()
-{
-   if (obj)
-      ResourceManager->unlock( obj );
-}
-
 #define INVALID_ID ((U32)(~0))

 //----------------------------------------------------------------------------
@@ -471,4 +387,88 @@
 #endif
 };
#3
11/26/2004 (7:07 pm)
+//------------------------------------------------------------------------------
+/// Wrapper class around a ResourceInstance subclass.
+///
+/// @code
+///    // Loading a resource...
+///    Resource<TerrainFile> terrRes;
+///
+///    terrRes = ResourceManager->load(fileName);
+///    if(!bool(terrRes))
+///       Con::errorf(ConsoleLogEntry::General, "Terraformer::terrainFile - invalid terrain file '%s'.", fileName);
+/// @endcode
+///
+/// When the Resource<> is destroyed, it frees the lock on the resource.
+///
+/// @see ResManager
+template <class T> class Resource
+{
+private:
+   ResourceObject *obj;  ///< Actual resource object
+
+   // ***WARNING***
+   // Using a faster lock that bypasses the resource manger.
+   // void _lock() { if (obj) obj->rm->lockResource( obj ); }
+   void _lock();   ///< Increments the lock count on this object
+   void _unlock(); ///< Decrements the lock count on this object
+
+public:
+   /// If assigned a ResourceObject, it's assumed to already have
+   /// been locked, lock count is incremented only for copies or
+   /// assignment from another Resource.
+   Resource() : obj(NULL) { ; }
+   Resource(ResourceObject *p) : obj(p) { ; }
+   Resource(const Resource &res) : obj(res.obj) { _lock(); }
+   ~Resource() { unlock(); }  ///< Decrements the lock count on this object, and if the lock count is 0 afterwards,
+                              ///< adds the object to the timeoutList for deletion on execution of purge().
+
+   const char *getFilePath() const { return (obj ? obj->path : NULL); } ///< Returns the path of the file (without the actual name)
+   const char *getFileName() const { return (obj ? obj->name : NULL); } ///< Returns the actual file name (without the path)
+
+   Resource& operator= (ResourceObject *p) { _unlock(); obj = p; return *this; }
+   Resource& operator= (const Resource &r) { _unlock(); obj = r.obj; _lock(); return *this; }
+
+   U32 getCRC() { return (obj ? obj->crc : 0); }
+   bool isNull()   const { return ((obj == NULL) || (obj->mInstance == NULL)); }
+   operator bool() const { return ((obj != NULL) && (obj->mInstance != NULL)); }
+   T* operator->()   { return (T*)obj->mInstance; }
+   T& operator*()    { return *((T*)obj->mInstance); }
+   operator T*() const    { return (obj) ? (T*)obj->mInstance : (T*)NULL; }
+   const T* operator->() const  { return (const T*)obj->mInstance; }
+   const T& operator*() const   { return *((const T*)obj->mInstance); }
+   operator const T*() const    { return (obj) ? (const T*)obj->mInstance :  (const T*)NULL; }
+   void unlock();
+   void purge();
+};
+
+template<class T> inline void Resource<T>::unlock()
+{
+   if (obj) {
+      ResourceManager->unlock( obj );
+      obj=NULL;
+   }
+}
+
+template<class T> inline void Resource<T>::purge()
+{
+   if (obj) {
+      ResourceManager->unlock( obj );
+      if (obj->lockCount == 0)
+         ResourceManager->purge(obj);
+      obj = NULL;
+   }
+}
+template <class T> inline void Resource<T>::_lock()
+{
+   if (obj)
+      obj->lockCount++;
+}
+
+template <class T> inline void Resource<T>::_unlock()
+{
+   if (obj)
+      ResourceManager->unlock( obj );
+}
+
 #endif //_RESMANAGER_H_