Build fails with gcc 4 due to missing forward class declarartions

Bug #541255 reported by psorensen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Medium
Jeff Hill

Bug Description

When I try to compile base-3.14.7 with a gcc-4 compiler, I get error messages such as the following in the src/cas/generic directory:

../../../../src/cas/generic/casdef.h:513: error: ISO C++ forbids declaration of 'casPVI' with no type
../../../../src/cas/generic/casdef.h:513: error: expected ';' before '*' token

By adding a forward declaration such as "class casPVI;" before the structure definition a am able to compile.

Additional information:
I am now using the following patch to build base.

--- START PATCH ---

diff -uNr base-3.14.7-orig/src/cas/generic/casdef.h base-3.14.7/src/cas/generic/casdef.h
--- base-3.14.7-orig/src/cas/generic/casdef.h 2004-10-08 10:54:45.000000000 -0400
+++ base-3.14.7/src/cas/generic/casdef.h 2005-09-15 13:23:45.000000000 -0400
@@ -108,6 +108,7 @@
     pverAsyncCompletion };

 class casPV;
+class casPVI;
 class casCtx;
 class casChannel;

diff -uNr base-3.14.7-orig/src/cas/generic/inBuf.h base-3.14.7/src/cas/generic/inBuf.h
--- base-3.14.7-orig/src/cas/generic/inBuf.h 2003-04-16 16:57:56.000000000 -0400
+++ base-3.14.7/src/cas/generic/inBuf.h 2005-09-15 15:25:18.000000000 -0400
@@ -27,6 +27,8 @@

 #include "clientBufMemoryManager.h"

+class inBuf;
+
 class inBufCtx {
     friend class inBuf;
 public:
diff -uNr base-3.14.7-orig/src/cas/generic/ioBlocked.h base-3.14.7/src/cas/generic/ioBlocked.h
--- base-3.14.7-orig/src/cas/generic/ioBlocked.h 2003-02-12 14:06:09.000000000 -0500
+++ base-3.14.7/src/cas/generic/ioBlocked.h 2005-09-15 13:26:03.000000000 -0400
@@ -31,6 +31,8 @@
 # include "shareLib.h"
 #endif

+class ioBlockedList;
+
 class ioBlocked : public tsDLNode < ioBlocked > {
 friend class ioBlockedList;
 public:
diff -uNr base-3.14.7-orig/src/cas/generic/outBuf.h base-3.14.7/src/cas/generic/outBuf.h
--- base-3.14.7-orig/src/cas/generic/outBuf.h 2003-02-12 14:06:10.000000000 -0500
+++ base-3.14.7/src/cas/generic/outBuf.h 2005-09-15 15:24:42.000000000 -0400
@@ -26,6 +26,8 @@
 #include "casdef.h"
 #include "clientBufMemoryManager.h"

+class outBuf;
+
 //
 // outBufCtx
 //
diff -uNr base-3.14.7-orig/src/cas/generic/st/casDGIntfOS.h base-3.14.7/src/cas/generic/st/casDGIntfOS.h
--- base-3.14.7-orig/src/cas/generic/st/casDGIntfOS.h 2003-03-10 17:26:32.000000000 -0500
+++ base-3.14.7/src/cas/generic/st/casDGIntfOS.h 2005-09-15 15:29:59.000000000 -0400
@@ -19,6 +19,10 @@
 #include "casDGIOWakeup.h"
 #include "casDGEvWakeup.h"

+class casDGReadReg;
+class casDGBCastReadReg;
+class casDGWriteReg;
+
 class casDGIntfOS : public casDGIntfIO {
     friend class casDGReadReg;
     friend class casDGBCastReadReg;
diff -uNr base-3.14.7-orig/src/cas/generic/st/casIntfOS.h base-3.14.7/src/cas/generic/st/casIntfOS.h
--- base-3.14.7-orig/src/cas/generic/st/casIntfOS.h 2003-03-10 17:26:32.000000000 -0500
+++ base-3.14.7/src/cas/generic/st/casIntfOS.h 2005-09-15 15:30:52.000000000 -0400
@@ -22,6 +22,8 @@
 #include "casIntfIO.h"
 #include "casDGIntfOS.h"

+class casServerReg;
+
 //
 // casIntfOS
 //

--- END PATCH ---

Original Mantis Bug: mantis-216
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=216

Tags: 3.14 build
Revision history for this message
markwag (markwag) wrote :

I can confirm that this patch fixes the missing-forward-class-definitions problem.

host: x86-linux
gcc (GCC) 4.0.1 (Debian 4.0.1-2)

target: vxWorks-68040
gcc-2.96

Revision history for this message
Jeff Hill (johill-lanl) wrote :

I committed a fix, but can't test it because I don’t have gcc 4.0 installed here (it's not yet available from cygwin and my linux system isn’t that new).

cvs diff -- casdef.h (in directory D:\users\hill\epicsDvl\epics\base\src\cas\generic\)
Index: casdef.h
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/cas/generic/casdef.h,v
retrieving revision 1.60
diff -c -r1.60 casdef.h
*** casdef.h 5 Aug 2005 20:54:36 -0000 1.60
--- casdef.h 26 Oct 2005 18:46:30 -0000
***************
*** 108,113 ****
--- 108,114 ----
      pverAsyncCompletion };

  class casPV;
+ class casPVI;
  class casCtx;
  class casChannel;

***** CVS exited normally with code 1 *****

Revision history for this message
Jeff Hill (johill-lanl) wrote :

from ernest

Works fine also on:
Fedora Core release 4
Linux matrix 2.6.13-1.1526_FC4
gcc version 4.0.1 20050919 (Red Hat 4.0.1-14)

from eric

Works fine on OS X with
powerpc-apple-darwin8-gcc-4.0.0 (GCC) 4.0.0 (Apple Computer, Inc. build 5026)

Revision history for this message
Jeff Hill (johill-lanl) wrote :

fixed in R3.14.8

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.8 Release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.