* 3.2.2 c++ compile problems @ 2002-12-23 9:53 Jack Howarth 2002-12-23 10:11 ` Craig Rodrigues 2002-12-23 10:50 ` Jack Howarth 0 siblings, 2 replies; 7+ messages in thread From: Jack Howarth @ 2002-12-23 9:53 UTC (permalink / raw) To: gcc Hello, Can anyone shed some light on which abi change in the g++ 3.2.x compiler is causing the following compile error. I am trying to build the sparky package from... http://www.cgl.ucsf.edu/home/sparky/ and I get the following compile time errors under gcc 3.2.2... g++ -O2 -fPIC -fpermissive -c brukerfile.cc In file included from /usr/include/c++/3.2.1/backward/fstream.h:31, from brukerfile.cc:33: /usr/include/c++/3.2.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substit brukerfile.cc: In constructor `Bruker_Params::Bruker_Params(const Stringy&)': brukerfile.cc:223: could not convert `bp' to `istream&' brukerfile.cc:101: in passing argument 1 of `bool read_parameter_entry(istream&, Stringy*, Stringy*)' make[1]: *** [brukerfile.o] Error 1 make[1]: Leaving directory `/usr/local/src/sparky/c++' make: *** [all] Error 2 I find that brukerfile.cc at line 101 has... static bool read_parameter_entry(istream &strm, Stringy *tag, Stringy *value); and at line 223 has the section... Bruker_Params::Bruker_Params(const Stringy &path) { ifstream bp(path.cstring()); Stringy tag, value; while (read_parameter_entry(bp, &tag, &value)) { tags.append(new Stringy(tag)); values.append(new Stringy(value)); } } Thanks in advance for any hints on how to solve this. Jack ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.2.2 c++ compile problems 2002-12-23 9:53 3.2.2 c++ compile problems Jack Howarth @ 2002-12-23 10:11 ` Craig Rodrigues 2002-12-23 10:50 ` Jack Howarth 1 sibling, 0 replies; 7+ messages in thread From: Craig Rodrigues @ 2002-12-23 10:11 UTC (permalink / raw) To: Jack Howarth; +Cc: gcc On Mon, Dec 23, 2002 at 12:18:18PM -0500, Jack Howarth wrote: > Hello, > Can anyone shed some light on which abi change in the g++ 3.2.x > compiler is causing the following compile error. I am trying to build > the sparky package from... > > > http://www.cgl.ucsf.edu/home/sparky/ > > and I get the following compile time errors under gcc 3.2.2... > > g++ -O2 -fPIC -fpermissive -c brukerfile.cc > In file included from /usr/include/c++/3.2.1/backward/fstream.h:31, > from brukerfile.cc:33: > /usr/include/c++/3.2.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substit > brukerfile.cc: In constructor `Bruker_Params::Bruker_Params(const Stringy&)': > brukerfile.cc:223: could not convert `bp' to `istream&' > brukerfile.cc:101: in passing argument 1 of `bool > read_parameter_entry(istream&, Stringy*, Stringy*)' > make[1]: *** [brukerfile.o] Error 1 > make[1]: Leaving directory `/usr/local/src/sparky/c++' > make: *** [all] Error 2 The sparky source code seems to have several forward declarations which are wrong. For example, in stringc.h: 3 #ifndef STRING_HEADER_INCLUDED 4 #define STRING_HEADER_INCLUDED 5 6 #include <stdarg.h> 7 8 #undef NULL // Fix bad define in stddef.h gnu distribution. 9 #define NULL 0L 10 11 class istream; 12 class ostream; You need to replace lines 11 and lines 12 with: #include <iosfwd> using namespace std; The reason for this is that istream and ostream are not classes in Standard C++. They are typedefs for templates. Look in <iosfwd> to see what I am referring to. You need to make this change in: format.h nmrdata.h rectangle.h savefile.h stringc.h -- Craig Rodrigues http://www.gis.net/~craigr rodrigc@attbi.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.2.2 c++ compile problems 2002-12-23 9:53 3.2.2 c++ compile problems Jack Howarth 2002-12-23 10:11 ` Craig Rodrigues @ 2002-12-23 10:50 ` Jack Howarth 2002-12-23 11:24 ` Gabriel Dos Reis 2002-12-23 11:56 ` Craig Rodrigues 1 sibling, 2 replies; 7+ messages in thread From: Jack Howarth @ 2002-12-23 10:50 UTC (permalink / raw) To: Craig Rodrigues; +Cc: gcc Craig, Thanks. That improved things a bit. Now I get the following errors... g++ -O2 -fPIC -fpermissive -c command.cc In file included from /usr/include/c++/3.2.1/backward/strstream:51, from /usr/include/c++/3.2.1/backward/strstream.h:33, from undo.h:10, from command.cc:34: /usr/include/c++/3.2.1/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substit In file included from /usr/include/c++/3.2.1/bits/stl_algobase.h:69, from /usr/include/c++/3.2.1/memory:54, from /usr/include/c++/3.2.1/string:48, from /usr/include/c++/3.2.1/bits/localefwd.h:49, from /usr/include/c++/3.2.1/ios:48, from /usr/include/c++/3.2.1/backward/strstream:53, from /usr/include/c++/3.2.1/backward/strstream.h:33, from undo.h:10, from command.cc:34: /usr/include/c++/3.2.1/new:79: declaration of `void* operator new(unsigned int) throw (std::bad_alloc)' throws different exceptions memalloc.h:22: than previous declaration `void* operator new(unsigned int)' /usr/include/c++/3.2.1/new:80: declaration of `void* operator new [](unsigned int) throw (std::bad_alloc)' throws different exceptions memalloc.h:25: than previous declaration `void* operator new [](unsigned int)' /usr/include/c++/3.2.1/new:81: declaration of `void operator delete(void*) throw ()' throws different exceptions memalloc.h:23: than previous declaration `void operator delete(void*)' /usr/include/c++/3.2.1/new:82: declaration of `void operator delete [](void*) throw ()' throws different exceptions memalloc.h:26: than previous declaration `void operator delete [](void*)' make: *** [command.o] Error 1 which has... void *operator new(size_t size); void operator delete(void *p); void *operator new[](size_t size); void operator delete[](void *p); at line 22. I assume this is an abi change too? What is the best approach for that one? I'm am going to pass all of this back upstream to the author. Thanks again for any help. Jack ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.2.2 c++ compile problems 2002-12-23 10:50 ` Jack Howarth @ 2002-12-23 11:24 ` Gabriel Dos Reis 2002-12-23 11:56 ` Craig Rodrigues 1 sibling, 0 replies; 7+ messages in thread From: Gabriel Dos Reis @ 2002-12-23 11:24 UTC (permalink / raw) To: Jack Howarth; +Cc: Craig Rodrigues, gcc Jack Howarth <howarth@bromo.med.uc.edu> writes: [...] | which has... | | void *operator new(size_t size); | void operator delete(void *p); | | void *operator new[](size_t size); | void operator delete[](void *p); | | at line 22. I assume this is an abi change too? What is the best approach | for that one? I'm am going to pass all of this back upstream to the | author. Thanks again for any help. Hand forward declaring standard entities is Bad Practice. Please, consider #includeing standard headers instead. For memory management, consider <new>. -- Gaby ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.2.2 c++ compile problems 2002-12-23 10:50 ` Jack Howarth 2002-12-23 11:24 ` Gabriel Dos Reis @ 2002-12-23 11:56 ` Craig Rodrigues 2002-12-23 13:02 ` Joe Buck 1 sibling, 1 reply; 7+ messages in thread From: Craig Rodrigues @ 2002-12-23 11:56 UTC (permalink / raw) To: Jack Howarth; +Cc: gcc [-- Attachment #1: Type: text/plain, Size: 733 bytes --] On Mon, Dec 23, 2002 at 01:00:11PM -0500, Jack Howarth wrote: > Craig, > Thanks. That improved things a bit. Now I get the following > errors... > > throw (std::bad_alloc)' throws different exceptions > memalloc.h:22: than previous declaration `void* operator new(unsigned int)' > /usr/include/c++/3.2.1/new:80: declaration of `void* operator new [](unsigned I suggest that you purchase a book which discusses Standard C++ in detail, such as Bjarne Stroustrup's C++ Programming Language, 3rd ed. g++ 3.x conforms quite closely to Standard C++, so understanding this standard will help you fix these types of problems. See the attached patch. -- Craig Rodrigues http://www.gis.net/~craigr rodrigc@attbi.com [-- Attachment #2: sparky-patch.txt --] [-- Type: text/plain, Size: 3145 bytes --] --- sparky/c++/memalloc.h.orig Mon Dec 23 13:10:42 2002 +++ sparky/c++/memalloc.h Mon Dec 23 13:11:41 2002 @@ -19,11 +19,16 @@ #include <stddef.h> // use size_t +#if __GNUC__ >= 3 +#include <new> +using namespace std; +#else void *operator new(size_t size); void operator delete(void *p); void *operator new[](size_t size); void operator delete[](void *p); +#endif // ---------------------------------------------------------------------------- // The lines below are for tracking all memory allocated with new. --- sparky/c++/nmrdata.h.orig Mon Dec 23 13:12:05 2002 +++ sparky/c++/nmrdata.h Mon Dec 23 13:16:51 2002 @@ -9,7 +9,12 @@ #include "spoint.h" // Use SPoint, IPoint, IRegion #include "stringc.h" // Use Stringy +#if __GNUC__ >= 3 +#include <iosfwd> +using namespace std; +#else class ostream; +#endif class Block_File; --- sparky/c++/format.h.orig Mon Dec 23 13:13:57 2002 +++ sparky/c++/format.h Mon Dec 23 13:13:15 2002 @@ -4,8 +4,13 @@ #ifndef FORMAT_HEADER_INCLUDED #define FORMAT_HEADER_INCLUDED +#if __GNUC__ >= 3 +#include <iosfwd> +using namespace std; +#else class istream; class ostream; +#endif class Condition; class Object_Table; --- sparky/c++/stringc.h.orig Mon Dec 23 13:14:32 2002 +++ sparky/c++/stringc.h Mon Dec 23 13:14:54 2002 @@ -8,8 +8,14 @@ #undef NULL // Fix bad define in stddef.h gnu distribution. #define NULL 0L +#if __GNUC__ >= 3 +#include <iosfwd> +using namespace std; +#else class istream; class ostream; +#endif + class List; class Stringy --- sparky/c++/savefile.h.orig Mon Dec 23 13:19:28 2002 +++ sparky/c++/savefile.h Mon Dec 23 13:19:32 2002 @@ -9,7 +9,13 @@ #include "list.h" // Use List #include "stringc.h" // Use Stringy +#if __GNUC__ >= 3 +#include <iosfwd> +using namespace std; +#else class ostream; +#endif + class Session; enum SAVEFILE_TYPE { --- sparky/c++/memalloc.cc.orig Mon Dec 23 13:20:53 2002 +++ sparky/c++/memalloc.cc Mon Dec 23 13:24:58 2002 @@ -11,8 +11,10 @@ #include "table.h" // use Table #include "utility.h" // use fatal_error() +#if __GNUC__ < 3 #undef new #undef delete +#endif // ---------------------------------------------------------------------------- // @@ -40,6 +42,9 @@ // ---------------------------------------------------------------------------- // void *operator new(size_t size) +#if __GNUC__ >= 3 + throw(std::bad_alloc) +#endif { void *value = allocate(size); if (tracking_memory) @@ -73,6 +78,9 @@ // ---------------------------------------------------------------------------- // void *operator new[](size_t size) +#if __GNUC__ >= 3 + throw(std::bad_alloc) +#endif { void *value = allocate(size); if (tracking_memory) @@ -92,6 +100,9 @@ // ---------------------------------------------------------------------------- // void operator delete(void *p) +#if __GNUC__ >= 3 + throw() +#endif { if (tracking_memory) forget(p); @@ -101,6 +112,9 @@ // ---------------------------------------------------------------------------- // void operator delete[](void *p) +#if __GNUC__ >= 3 + throw() +#endif { if (tracking_memory) forget(p); ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.2.2 c++ compile problems 2002-12-23 11:56 ` Craig Rodrigues @ 2002-12-23 13:02 ` Joe Buck 2002-12-23 13:02 ` Craig Rodrigues 0 siblings, 1 reply; 7+ messages in thread From: Joe Buck @ 2002-12-23 13:02 UTC (permalink / raw) To: Craig Rodrigues; +Cc: gcc On Mon, Dec 23, 2002 at 01:29:08PM -0500, Craig Rodrigues wrote: > g++ 3.x conforms quite closely to Standard C++, so understanding > this standard will help you fix these types of problems. > > See the attached patch. Craig, your patch seems to assume that the compiler will always be GCC: you test for GCC 3, and otherwise explicitly declare new and delete in the global namespace (which is correct only for GCC 2). > #include <stddef.h> // use size_t > > +#if __GNUC__ >= 3 > +#include <new> > +using namespace std; > +#else > void *operator new(size_t size); > void operator delete(void *p); > > void *operator new[](size_t size); > void operator delete[](void *p); > +#endif This should probably be reversed, making GCC 2 the nonstandard environment to test for. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 3.2.2 c++ compile problems 2002-12-23 13:02 ` Joe Buck @ 2002-12-23 13:02 ` Craig Rodrigues 0 siblings, 0 replies; 7+ messages in thread From: Craig Rodrigues @ 2002-12-23 13:02 UTC (permalink / raw) To: gcc On Mon, Dec 23, 2002 at 11:55:52AM -0800, Joe Buck wrote: > Craig, your patch seems to assume that the compiler will always be GCC: > you test for GCC 3, and otherwise explicitly declare new and delete > in the global namespace (which is correct only for GCC 2). The Makefile for the sparky program is hardcoded to use GCC, and probably won't work with anything besides GCC. Yes, inverting the logic to test for GCC2 by default is easy to do. -- Craig Rodrigues http://www.gis.net/~craigr rodrigc@attbi.com ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-12-23 20:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-12-23 9:53 3.2.2 c++ compile problems Jack Howarth 2002-12-23 10:11 ` Craig Rodrigues 2002-12-23 10:50 ` Jack Howarth 2002-12-23 11:24 ` Gabriel Dos Reis 2002-12-23 11:56 ` Craig Rodrigues 2002-12-23 13:02 ` Joe Buck 2002-12-23 13:02 ` Craig Rodrigues
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).