home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / linux / 23737 < prev    next >
Encoding:
Text File  |  1993-01-12  |  11.5 KB  |  303 lines

  1. Path: sparky!uunet!charon.amdahl.com!amdahl!JUTS!duts!pac30
  2. From: pac30@duts.ccc.amdahl.com (Paul Caffrey)
  3. Newsgroups: comp.os.linux
  4. Subject: linux 0.98 c++ streams
  5. Message-ID: <44GB02r7319g01@JUTS.ccc.amdahl.com>
  6. Date: 11 Jan 93 13:43:52 GMT
  7. Sender: netnews@ccc.amdahl.com
  8. Reply-To: pac30@DUTS.ccc.amdahl.com (Paul Caffrey)
  9. Organization: Amdahl Corporation, Sunnyvale CA
  10. Lines: 291
  11.  
  12. Hi,
  13.  
  14. I can't get the c++ stream io implementation of the 0.98 linux SLS distribution working.
  15.  
  16. The following program(cout.c): 
  17.  
  18. #include <iostream.h>
  19. main(){
  20. cout << "Hello World!\n";
  21. }
  22.  
  23. fails to compile (g++ cout.c) with the following message:
  24.  
  25.  
  26. cout.o: Undefined symbol _cout referenced from text segment
  27. cout.o: Undefined symbol operator<<(ostream &, const char *) referenced from text segment
  28.  
  29. Can anyone explain why this happens? All other c++ appear to be working. 
  30. ps while I'm on is there a "dissambler" program for linux?
  31. Paul
  32. email pac30@amail.amdahl.com
  33.  
  34. ps the following is the file iostream.h
  35.  
  36. //    This is part of the iostream library, providing -*- C++ -*- input/output.
  37. //    Copyright (C) 1991 Per Bothner.
  38. //
  39. //    This library is free software; you can redistribute it and/or
  40. //    modify it under the terms of the GNU Library General Public
  41. //    License as published by the Free Software Foundation; either
  42. //    version 2 of the License, or (at your option) any later version.
  43. //
  44. //    This library is distributed in the hope that it will be useful,
  45. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  46. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  47. //    Library General Public License for more details.
  48. //
  49. //    You should have received a copy of the GNU Library General Public
  50. //    License along with this library; if not, write to the Free
  51. //    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  52.  
  53. #ifndef _IOSTREAM_H
  54. #ifdef __GNUG__
  55. #pragma interface
  56. #endif
  57. #define _IOSTREAM_H
  58. #define Q_ENV
  59.  
  60. #include <streambuf.h>
  61.  
  62. class istream; class ostream;
  63. typedef ios& (*__manip)(ios&);
  64. typedef istream& (*__imanip)(istream&);
  65. typedef ostream& (*__omanip)(ostream&);
  66.  
  67. extern istream& ws(istream& ins);
  68. extern ostream& flush(ostream& outs);
  69. extern ostream& endl(ostream& outs);
  70. extern ostream& ends(ostream& outs);
  71.  
  72. class ostream : public ios
  73. {
  74.     void do_osfx();
  75.   public:
  76.     ostream() { }
  77.     ostream(streambuf* sb, ostream* tied=NULL);
  78.     int opfx() { if (!good()) return 0; if (_tie) _tie->flush(); return 1; }
  79.     void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
  80.               do_osfx(); }
  81.     streambuf* ostreambuf() const { return _strbuf; }
  82.     ostream& flush();
  83.     ostream& put(char c) { _strbuf->sputc(c); return *this; }
  84.  
  85.     ostream& write(const char *s, int n);
  86.     ostream& write(const unsigned char *s, int n) { return write((const char*)s, n);}
  87. #ifndef _G_BROKEN_SIGNED_CHAR
  88.     ostream& write(const signed char *s, int n) { return write((const char*)s, n);}
  89. #endif
  90.     ostream& write(const void *s, int n) { return write((const char*)s, n);}
  91.     ostream& seekp(streampos);
  92.     ostream& seekp(streamoff, _seek_dir);
  93.     streampos tellp();
  94.     ostream& form(const char *format ...);
  95.     ostream& vform(const char *format, _G_va_list args);
  96. };
  97.  
  98. extern ostream& operator<<(ostream&, char c);
  99. inline ostream& operator<<(ostream& os, unsigned char c)
  100. { return os << (char)c; }
  101. #ifndef _G_BROKEN_SIGNED_CHAR
  102. extern ostream& operator<<(ostream &os, signed char c) { return os << (char)c;}
  103. #endif
  104. extern ostream& operator<<(ostream&, const char *s);
  105. inline ostream& operator<<(ostream& os, const unsigned char *s)
  106. { return os << (const char*)s; }
  107. #ifndef _G_BROKEN_SIGNED_CHAR
  108. inline ostream& operator<<(ostream& os, const signed char *s)
  109. { return os << (const char*)s; }
  110. #endif
  111. extern ostream& operator<<(ostream&, void *p);
  112. extern ostream& operator<<(ostream&, int n);
  113. extern ostream& operator<<(ostream&, long n);
  114. extern ostream& operator<<(ostream&, unsigned int n);
  115. extern ostream& operator<<(ostream&, unsigned long n);
  116. inline ostream& operator<<(ostream& os, short n) {return os << (int)n;}
  117. inline ostream& operator<<(ostream& os, unsigned short n)
  118. {return os << (unsigned int)n;}
  119. extern ostream& operator<<(ostream&, float n);
  120. extern ostream& operator<<(ostream&, double n);
  121. inline ostream& operator<<(ostream& os, __omanip func) { return (*func)(os); }
  122. inline ostream& operator<<(ostream& os, __manip func) {(*func)(os); return os;}
  123. extern ostream& operator<<(ostream&, streambuf*);
  124.  
  125. class istream : public ios
  126. {
  127.     _G_ssize_t _gcount;
  128.  
  129.     int _skip_ws();
  130.   public:
  131.     istream() { _gcount = 0; }
  132.     istream(streambuf* sb, ostream*tied=NULL);
  133.     streambuf* istreambuf() const { return _strbuf; }
  134.     istream& get(char& c);
  135.     istream& get(unsigned char& c) { return get((char&)c); }
  136. #ifndef _G_BROKEN_SIGNED_CHAR
  137.     istream& get(signed char& c)  { return get((char&)c); }
  138. #endif
  139.     istream& read(char *ptr, int n);
  140.     istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
  141. #ifndef _G_BROKEN_SIGNED_CHAR
  142.     istream& read(signed char *ptr, int n) { return read((char*)ptr, n); }
  143. #endif
  144.     istream& read(void *ptr, int n) { return read((char*)ptr, n); }
  145.     // Should get() and/or peek() set failbit and/or eofbit? FIXME!
  146.     istream& getline(char* ptr, int len, char delim = '\n');
  147.     istream& get(char* ptr, int len, char delim = '\n');
  148.     istream& get(streambuf& sb, char delim = '\n');
  149.     istream& gets(char **s, char delim = '\n');
  150.     int ipfx(int need) {
  151.     if (!good()) { set(ios::failbit); return 0; }
  152.     if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
  153.     if (!need && (flags() & ios::skipws)) return _skip_ws();
  154.     return 1;
  155.     }
  156.     int ipfx0() { // Optimized version of ipfx(0).
  157.     if (!good()) { set(ios::failbit); return 0; }
  158.     if (_tie) _tie->flush();
  159.     if (flags() & ios::skipws) return _skip_ws();
  160.     return 1;
  161.     }
  162.     int ipfx1() { // Optimized version of ipfx(1).
  163.     if (!good()) { set(ios::failbit); return 0; }
  164.     if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
  165.     return 1;
  166.     }
  167.     int get() { if (!ipfx1()) return EOF;
  168.         int ch = _strbuf->sbumpc();
  169.         if (ch == EOF) set(ios::eofbit);
  170.         return ch; }
  171.     int peek() { if (!ipfx1()) return EOF;
  172.         int ch = _strbuf->sgetc();
  173.         if (ch == EOF) set(ios::eofbit);
  174.         return ch; }
  175.     _G_ssize_t gcount() { return _gcount; }
  176.     istream& ignore(int n=1, int delim = EOF);
  177.     istream& seekg(streampos);
  178.     istream& seekg(streamoff, _seek_dir);
  179.     streampos tellg();
  180.     istream& putback(char ch) {
  181.     if (good() && _strbuf->sputbackc(ch) == EOF) clear(ios::badbit);
  182.     return *this;}
  183.     istream& unget() {
  184.     if (good() && _strbuf->sungetc() == EOF) clear(ios::badbit);
  185.     return *this;}
  186.     istream& scan(const char *format ...);
  187.     istream& vscan(const char *format, _G_va_list args);
  188. #ifdef _STREAM_COMPAT
  189.     istream& unget(char ch) { return putback(ch); }
  190.     int skip(int i);
  191. #endif
  192. };
  193.  
  194. extern istream& operator>>(istream&, char*);
  195. inline istream& operator>>(istream& is, unsigned char* p)
  196. { return is >> (char*)p; }
  197. #ifndef _G_BROKEN_SIGNED_CHAR
  198. inline istream& operator>>(istream& is, signed char*p) {return is >> (char*)p;}
  199. #endif
  200. extern istream& operator>>(istream&, char& c);
  201. extern istream& operator>>(istream& s, unsigned char& c) {return s>>(char&)c;}
  202. #ifndef _G_BROKEN_SIGNED_CHAR
  203. extern istream& operator>>(istream& s, signed char& c) {return s >> (char&)c;}
  204. #endif
  205. extern istream& operator>>(istream&, int&);
  206. extern istream& operator>>(istream&, long&);
  207. extern istream& operator>>(istream&, short&);
  208. extern istream& operator>>(istream&, unsigned int&);
  209. extern istream& operator>>(istream&, unsigned long&);
  210. extern istream& operator>>(istream&, unsigned short&);
  211. extern istream& operator>>(istream&, float&);
  212. extern istream& operator>>(istream&, double&);
  213. inline istream& operator>>(istream& is, __manip func) {(*func)(is); return is;}
  214. inline istream& operator>>(istream& is, __imanip func) { return (*func)(is); }
  215. extern istream& operator>>(istream&, streambuf*);
  216.  
  217. class iostream : public ios {
  218.     _G_ssize_t _gcount;
  219.   public:
  220.     iostream() { _gcount = 0; }
  221.     iostream(streambuf* sb, ostream*tied=NULL);
  222.     operator istream&() { return *(istream*)this; }
  223.     operator ostream&() { return *(ostream*)this; }
  224.     // NOTE: These duplicate istream methods.
  225.     istream& get(char& c) { return ((istream*)this)->get(c); }
  226.     istream& get(unsigned char& c) { return ((istream*)this)->get((char&)c); }
  227. #ifndef _G_BROKEN_SIGNED_CHAR
  228.     istream& get(signed char& c) { return ((istream*)this)->get((char&)c); }
  229. #endif
  230.     istream& read(char *ptr, int n) { return ((istream*)this)->read(ptr, n); }
  231.     istream& read(unsigned char *ptr, int n)
  232.     { return ((istream*)this)->read((char*)ptr, n); }
  233. #ifndef _G_BROKEN_SIGNED_CHAR
  234.     istream& read(signed char *ptr, int n)
  235.     { return ((istream*)this)->read((char*)ptr, n); }
  236. #endif
  237.     istream& read(void *ptr, int n)
  238.     { return ((istream*)this)->read((char*)ptr, n); }
  239.     istream& getline(char* ptr, int len, char delim = '\n')
  240.     { return ((istream*)this)->getline(ptr, len, delim); }
  241.     istream& get(char* ptr, int len, char delim = '\n')
  242.     { return ((istream*)this)->get(ptr, len, delim); }
  243.     istream& gets(char **s, char delim = '\n')
  244.     { return ((istream*)this)->gets(s, delim); }
  245.     istream& ignore(int n=1, int delim = EOF)
  246.     { return ((istream*)this)->ignore(n, delim); }
  247.     int ipfx(int need) { return ((istream*)this)->ipfx(need); }
  248.     int ipfx0()  { return ((istream*)this)->ipfx0(); }
  249.     int ipfx1()  { return ((istream*)this)->ipfx1(); }
  250.     int get() { return _strbuf->sbumpc(); }
  251.     int peek() { return ipfx1() ? _strbuf->sgetc() : EOF; }
  252.     _G_ssize_t gcount() { return _gcount; }
  253.     istream& putback(char ch) { return ((istream*)this)->putback(ch); }
  254.     istream& unget() { return ((istream*)this)->unget(); }
  255.     istream& seekg(streampos pos) { return ((istream*)this)->seekg(pos); }
  256.     istream& seekg(streamoff off, _seek_dir dir)
  257.     { return ((istream*)this)->seekg(off, dir); }
  258.     streampos tellg() { return ((istream*)this)->tellg(); }
  259.     istream& scan(const char *format ...);
  260.     istream& vscan(const char *format, _G_va_list args)
  261.     { return ((istream*)this)->vscan(format, args); }
  262. #ifdef _STREAM_COMPAT
  263.     istream& unget(char ch) { return putback(ch); }
  264. #endif
  265.  
  266.     // NOTE: These duplicate ostream methods.
  267.     int opfx() { return ((ostream*)this)->opfx(); }
  268.     void osfx() { ((ostream*)this)->osfx(); }
  269.     ostream& flush() { return ((ostream*)this)->flush(); }
  270.     ostream& put(char c) { return ((ostream*)this)->put(c); }
  271.     ostream& write(const char *s, int n)
  272.     { return ((ostream*)this)->write(s, n); }
  273.     ostream& write(const unsigned char *s, int n)
  274.     { return ((ostream*)this)->write((const char*)s, n); }
  275. #ifndef _G_BROKEN_SIGNED_CHAR
  276.     ostream& write(const signed char *s, int n)
  277.     { return ((ostream*)this)->write((const char*)s, n); }
  278. #endif
  279.     ostream& write(const void *s, int n)
  280.     { return ((ostream*)this)->write((const char*)s, n); }
  281.     ostream& form(const char *format ...);
  282.     ostream& vform(const char *format, _G_va_list args)
  283.     { return ((ostream*)this)->vform(format, args); }
  284.     ostream& seekp(streampos pos) { return ((ostream*)this)->seekp(pos); }
  285.     ostream& seekp(streamoff off, _seek_dir dir)
  286.     { return ((ostream*)this)->seekp(off, dir); }
  287.     streampos tellp() { return ((ostream*)this)->tellp(); }
  288. };
  289.  
  290. extern istream cin;
  291. extern ostream cout, cerr, clog; // clog->rdbuf() == cerr->rdbuf()
  292.  
  293. struct Iostream_init { } ;  // Compatibility hack for AT&T libraray.
  294.  
  295. inline ios& dec(ios& i)
  296. { i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
  297. inline ios& hex(ios& i)
  298. { i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
  299. inline ios& oct(ios& i)
  300. { i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
  301.  
  302. #endif /*!_IOSTREAM_H*/
  303.