Opened 18 years ago

Closed 18 years ago

#11 closed defect (fixed)

FdoPool - Clear() method illegal C++ code?

Reported by: warmerdam Owned by: gavincramer
Priority: major Milestone: 3.3.0
Component: FDO API Version: 3.3.0
Severity: 3 Keywords:
Cc: gregboone External ID:

Description

Building Fdo trunk on Linux with gcc 3.4.5 results in the following error:

 g++ -DPACKAGE_NAME=\"FDO\" -DPACKAGE_TARNAME=\"fdo\" -DPACKAGE_VERSION=\"3.3.0\
" "-DPACKAGE_STRING=\"FDO 3.3.0\"" -DPACKAGE_BUGREPORT=\"http://fdo.osgeo.org\" 
-DPACKAGE=\"fdo\" -DVERSION=\"3.3.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHA
VE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STR
INGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=
1 -I. -I. -I../../Inc -I../Common -g -MMD -MT -DFULLPROTO -D__USE_GNU -MT Circul
arArcSegment.lo -MD -MP -MF .deps/CircularArcSegment.Tpo -c Fgf/CircularArcSegme
nt.cpp  -fPIC -DPIC -o .libs/CircularArcSegment.o
In file included from Fgf/GeometryFactory2.h:28,
                 from Fgf/CircularArcSegment.h:25,
                 from Fgf/CircularArcSegment.cpp:20:
Fgf/Pool.h: In destructor `virtual FdoPool<OBJ, EXC>::~FdoPool()':
Fgf/Pool.h:181: error: there are no arguments to `Clear' that depend on a templa
te parameter, so a declaration of `Clear' must be available
Fgf/Pool.h:181: error: (if you use `-fpermissive', G++ will accept your code, bu
t allowing the use of an undeclared name is deprecated)
In file included from Fgf/LineString.h:29,
                 from Fgf/GeometryFactory2.h:31,
                 from Fgf/CircularArcSegment.h:25,
                 from Fgf/CircularArcSegment.cpp:20:
Fgf/GeometryImpl.h: In member function `virtual void FdoFgfGeometryImpl<FDO_GEOM
ETRY_CLASS>::SetFgf(FdoByteArray*, const FdoByte*, FdoInt32)':
Fgf/GeometryImpl.h:68: error: invalid use of undefined type `struct FdoFgfGeomet
ryPools'
Fgf/GeometryImpl.h:28: error: forward declaration of `struct FdoFgfGeometryPools
'
Fgf/GeometryImpl.h: In member function `void FdoFgfGeometryImpl<FDO_GEOMETRY_CLA
SS>::SurrenderByteArray()':
Fgf/GeometryImpl.h:154: error: invalid use of undefined type `struct FdoFgfGeome
tryPools'
Fgf/GeometryImpl.h:28: error: forward declaration of `struct FdoFgfGeometryPools
'
make: *** [CircularArcSegment.lo] Error 1

I presume this is related to Gavin's recent merge from the 3.2.x branch. I don't know if the same problem exists in 3.2.x. I also don't know whether this is really bad C++ or just gcc producing spurious errors.

Change History (1)

in reply to:  description comment:1 by gavincramer, 18 years ago

Resolution: fixed
Status: newclosed

There were two issues in new code that newer GCC versions did not like.

One issue was a template's method call that needs explicit reference to the base type. I am not sure why this is needed, because there was no ambiguity. Regardless, the fix was trivial.

The second issue was dereferencing a pointer whose type was only forward-declared. The compiler was clearly correct in flagging this. The earlier compilers must have been pulling in the type through non-obvious means. The forward-declaration was to avoid a circular reference. The fix was to delegate from the given method (an inline function in a header file) to one that had the right type available (not inline, slightly slower, only called once in object's lifetime).

Both issues are fixed in the trunk with r2557, and in the 3.2.x branch with Revision 785.

Note: See TracTickets for help on using tickets.