octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] Building Octave with GCC 3.1


From: Mumit Khan
Subject: [patch] Building Octave with GCC 3.1
Date: Fri, 17 May 2002 18:01:04 -0500 (CDT)

Simple changes to support gcc-3.1. The only perhaps not so obvious change
is in Array<T>::resize_fill_value -- the old method of initializing the
return object using T(0) causes ambiguities, especially so when T is
octave_value (look at the octave_value::octave_value constructors to
see the reason for ambiguities), and so I've used the T() form.

Patch against CVS sources updated around 3pm, 5/17/2002. Build tested
against gcc-3.0.2 and gcc-3.1, both on i686-pc-linux-gnu. Could someone
please check against 2.95.x (and possibly against RedHat 7.x's gcc-2.96)?
I'll check Sun Workshop over the weekend.

liboctave/ChangeLog:
2002-05-17  Mumit Khan <address@hidden>

        * Array.h (Array<T>::resize_fill_value): Return default initialized
        object.

src/ChangeLog:
2002-05-17  Mumit Khan <address@hidden>

        * c-file-ptr-stream.h (OCTAVE_STD_FILEBUF): New macro to handle
        various forms of extensions to std::filebuf.
        (c_file_ptr_buf::c_file_ptr_buf): Use.
        * pt-idx.cc (tree_index_expression::tree_index_expression): Remove
        default arguments are from definition.
        * symtab.cc (SYMBOL_DEF::print_info): Add std::.
        (symbol_record::print_info): Likewise.
        (symbol_table::print_info): Likewise.

Index: liboctave/Array.h
===================================================================
RCS file: /cvs/octave/liboctave/Array.h,v
retrieving revision 1.59
diff -u -3 -p -r1.59 Array.h
--- liboctave/Array.h   2002/05/15 03:21:00     1.59
+++ liboctave/Array.h   2002/05/17 22:27:17
@@ -254,7 +254,7 @@ public:

 #endif

-  static T resize_fill_value (void) { return static_cast<T> (0); }
+  static T resize_fill_value (void) { return T (); }

   void print_info (std::ostream& os, const std::string& prefix) const;
 };
Index: src/c-file-ptr-stream.h
===================================================================
RCS file: /cvs/octave/src/c-file-ptr-stream.h,v
retrieving revision 1.6
diff -u -3 -p -r1.6 c-file-ptr-stream.h
--- src/c-file-ptr-stream.h     2001/06/27 02:29:03     1.6
+++ src/c-file-ptr-stream.h     2002/05/17 22:27:17
@@ -31,13 +31,37 @@ Software Foundation, 59 Temple Place - S
 #include <fstream>
 #include <cstdio>

+//
+// The c_file_ptr_buf requires a std::filebuf that accepts an open
+// file descriptor. This feature, while not part of the ISO C++
+// standard, is supported by a variety of C++ compiler runtimes,
+// albeit in slightly different ways.
+//
+// The C++ runtime libraries shipped with GCC versions < 3.0, Sun Pro,
+// Sun Workshop/Forte 5/6, Compaq C++ all support a non-standard filebuf
+// constructor that takes an open file descriptor. The almost ISO compliant
+// GNU C++ runtime shipped with GCC 3.0.x supports a different non-standard
+// filebuf constructor that takes a FILE* instead; starting from GCC 3.1,
+// the GNU C++ runtime removes all non-standard std::filebuf constructors
+// and provides an extension template class __gnu_cxx::stdio_filebuf
+// that supports the the 3.0.x behavior.
+//
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
+# include <ext/stdio_filebuf.h>
+# define OCTAVE_STD_FILEBUF __gnu_cxx::stdio_filebuf<char>
+#else
+# define OCTAVE_STD_FILEBUF std::filebuf
+#endif
+
 class
-c_file_ptr_buf : public std::filebuf
+c_file_ptr_buf : public OCTAVE_STD_FILEBUF
 {
 public:

 #if !defined (CXX_ISO_COMPLIANT_LIBRARY)
   typedef int int_type;
+#else
+  typedef std::filebuf::int_type int_type;
 #endif

   typedef int (*close_fcn) (FILE *);
@@ -47,9 +71,9 @@ public:
   c_file_ptr_buf (FILE *f_arg, close_fcn cf_arg = ::fclose)
     :
 #if defined __GNUC__ && __GNUC__ >= 3
-    std::filebuf (f_arg, std::ios::in | std::ios::out),
+    OCTAVE_STD_FILEBUF (f_arg, std::ios::in | std::ios::out),
 #else
-    std::filebuf (f_arg ? fileno (f_arg) : -1),
+    OCTAVE_STD_FILEBUF (f_arg ? fileno (f_arg) : -1),
 #endif
     f (f_arg), cf (cf_arg),
     fd (f_arg ? fileno (f_arg) : -1)
@@ -93,6 +117,8 @@ private:

   int fd;
 };
+
+#undef OCTAVE_STD_FILEBUF

 class
 i_c_file_ptr_stream : public std::istream
Index: src/pt-idx.cc
===================================================================
RCS file: /cvs/octave/src/pt-idx.cc,v
retrieving revision 1.12
diff -u -3 -p -r1.12 pt-idx.cc
--- src/pt-idx.cc       2002/05/15 03:21:01     1.12
+++ src/pt-idx.cc       2002/05/17 22:27:17
@@ -59,7 +59,7 @@ tree_index_expression::tree_index_expres

 tree_index_expression::tree_index_expression (tree_expression *e,
                                              const std::string& n,
-                                             int l = -1, int c = -1)
+                                             int l, int c)
   : tree_expression (l, c), expr (e), args (), type (), arg_nm ()
 {
   append (n);
Index: src/symtab.cc
===================================================================
RCS file: /cvs/octave/src/symtab.cc,v
retrieving revision 1.86
diff -u -3 -p -r1.86 symtab.cc
--- src/symtab.cc       2002/05/15 03:21:01     1.86
+++ src/symtab.cc       2002/05/17 22:27:17
@@ -178,7 +178,7 @@ SYMBOL_DEF::which (std::ostream& os, con
 }

 void
-SYMBOL_DEF::print_info (ostream& os, const std::string& prefix) const
+SYMBOL_DEF::print_info (std::ostream& os, const std::string& prefix) const
 {
   os << prefix << "symbol_def::count: " << count << "\n";

@@ -476,7 +476,7 @@ symbol_record::print_symbol_info_line (s
 }

 void
-symbol_record::print_info (ostream& os, const std::string& prefix) const
+symbol_record::print_info (std::ostream& os, const std::string& prefix) const
 {
   if (definition)
     definition->print_info (os, prefix);
@@ -874,7 +874,7 @@ symbol_table::pop_context (void)
 }

 void
-symbol_table::print_info (ostream& os) const
+symbol_table::print_info (std::ostream& os) const
 {
   int count = 0;
   int empty_chains = 0;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]