Article View: gnu.gcc.bug
Article #5912C++
From: Charles Teague
Date: Tue, 28 Jan 1997 00:00
Date: Tue, 28 Jan 1997 00:00
258 lines
7991 bytes
7991 bytes
Hi,
I noticed that you wrote some of the header files in the NeXTStep 3.2
library for C++. I am having trouble compling and simple C++ program.
If you have time could you tell me what I am doing wrong?
The errors follow:
fcl24> cc++ /Cplusplus/Source/advance2.cpp -lg++ -o
/Cplusplus/Programs/advance2
In file included from /Cplusplus/Source/advance2.cpp:4:
/NextDeveloper/Headers/g++/iomanip.h:61: parse error before `>'
/NextDeveloper/Headers/g++/iomanip.h:63: parse error before `>'
/NextDeveloper/Headers/g++/iomanip.h:141: semicolon missing after
declaration of `smanip<int>'
/NextDeveloper/Headers/g++/iomanip.h: In function `int setbase
(int)':
/NextDeveloper/Headers/g++/iomanip.h:141: aggregate value used where
an integer was expected
/NextDeveloper/Headers/g++/iomanip.h: At top level:
/NextDeveloper/Headers/g++/iomanip.h:61: parse error before `>'
/NextDeveloper/Headers/g++/iomanip.h:63: parse error before `>'
/NextDeveloper/Headers/g++/iomanip.h:146: semicolon missing after
declaration of `smanip<long unsigned int>'
/NextDeveloper/Headers/g++/iomanip.h: In function `int resetiosflags
(long unsigned int)':
/NextDeveloper/Headers/g++/iomanip.h:146: aggregate value used where
an integer was expected
cc: Internal compiler error: program cc1objplus got fatal signal 10
The advance2.cpp program follows:
// cc++ -Wall -O /Cplusplus/Source/advance2.cpp -lg++ -o
/Cplusplus/Programs/advance2
#include <iostream.h>
#include<iomanip.h>
/************************************************************/
#define INVALID_DEGREE -1
/************************************************************/
int main(void)
/************************************************************/
// advance2.cpp
// The following C++ program converts Celsius to Fahrenheit.
/************************************************************/
{
int DegreeInCelsius; /* The degree in Celsius
*/
double DegreeInFahrenheit; /* The degree in Fahrenheit
*/
cout << "Enter a degree in Celsius: ";
cin >> DegreeInCelsius;
while (DegreeInCelsius != INVALID_DEGREE) {
DegreeInFahrenheit = DegreeInCelsius * 1.8 + 32.0;
cout.width(7);
cout << DegreeInCelsius;
// cout << setw(9) << setpercision(2) << setiosflags(ios::fixed) <<
DegreeInFahrenheit;
cout << " ";
cout << DegreeInFahrenheit;
cout << "\nEnter a degree in Celsius (-1 terminates):
";
cin >> DegreeInCelsius;
} /* while */
cout << "\n\n ==> Successful Termination <== \n\a";
return(0);
} /* main */
/************************************************************/
The iomanip.h header file follows:
// -*- C++ -*-
// This is part of the iostream library, providing parametrized
manipulators
// Written by Heinz G. Seidl, Copyright (C) 1992 Cygnus Support
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later
version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General
Public
// License along with this library; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
USA.
#ifndef _IOMANIP_H
//
// Not specifying `pragma interface' causes the compiler to emit the
// template definitions in the files, where they are used.
//
//#ifdef __GNUG__
//#pragma interface
//#endif
#define _IOMANIP_H
#include <_G_config.h>
#ifndef _G_NO_TEMPLATES
#include <iostream.h>
//--------------------------------------------------------------------
---------
// Parametrized Manipulators as specified by ANSI draft
//--------------------------------------------------------------------
---------
//--------------------------------------------------------------------
---------
// Stream Manipulators
//--------------------------------------------------------------------
---------
//
template<class TP> class smanip; // TP = Type Param
template<class TP> class sapp {
ios& (*_f)(ios&, TP);
public:
sapp(ios& (*f)(ios&, TP)) : _f(f) {}
//
smanip<TP> operator()(TP a)
{ return smanip<TP>(_f, a); }
};
template <class TP> class smanip {
ios& (*_f)(ios&, TP);
TP _a;
public:
smanip(ios& (*f)(ios&, TP), TP a) : _f(f), _a(a) {}
//
friend
istream& operator>>(istream& i, const smanip<TP>& m);
friend
ostream& operator<<(ostream& o, const smanip<TP>& m);
};
template<class TP>
inline istream& operator>>(istream& i, const smanip<TP>& m)
{ m._f(i, m._a); return i; }
template<class TP>
inline ostream& operator<<(ostream& o, const smanip<TP>& m)
{ m._f(o, m._a); return o;}
//--------------------------------------------------------------------
---------
// Input-Stream Manipulators
//--------------------------------------------------------------------
---------
//
template<class TP> class imanip;
template<class TP> class iapp {
istream& (*_f)(istream&, TP);
public:
iapp(ostream& (*f)(istream&,TP)) : _f(f) {}
//
imanip<TP> operator()(TP a)
{ return imanip<TP>(_f, a); }
};
template <class TP> class imanip {
istream& (*_f)(istream&, TP);
TP _a;
public:
imanip(istream& (*f)(istream&, TP), TP a) : _f(f), _a(a) {}
//
friend
istream& operator>>(istream& i, const imanip<TP>& m)
{ return m._f( i, m._a); }
};
//--------------------------------------------------------------------
---------
// Output-Stream Manipulators
//--------------------------------------------------------------------
---------
//
template<class TP> class omanip;
template<class TP> class oapp {
ostream& (*_f)(ostream&, TP);
public:
oapp(ostream& (*f)(ostream&,TP)) : _f(f) {}
//
omanip<TP> operator()(TP a)
{ return omanip<TP>(_f, a); }
};
template <class TP> class omanip {
ostream& (*_f)(ostream&, TP);
TP _a;
public:
omanip(ostream& (*f)(ostream&, TP), TP a) : _f(f), _a(a) {}
//
friend
ostream& operator>>(ostream& i, imanip<TP>& m)
{ return (ostream&) m._f( i, m._a); }
};
//--------------------------------------------------------------------
---------
// Available Manipulators
//--------------------------------------------------------------------
---------
//
// Macro to define an iomanip function, with one argument
// The underlying function is `__iomanip_<name>'
//
#define __DEFINE_IOMANIP_FN1(type,param,function) \
extern ios& __iomanip_##function (ios&, param); \
inline type<param> function (param n) \
{ return type<param> (__iomanip_##function,
n); }
__DEFINE_IOMANIP_FN1( smanip, int, setbase)
__DEFINE_IOMANIP_FN1( smanip, int, setfill)
__DEFINE_IOMANIP_FN1( smanip, int, setprecision)
__DEFINE_IOMANIP_FN1( smanip, int, setw)
__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, resetiosflags)
__DEFINE_IOMANIP_FN1( smanip, ios::fmtflags, setiosflags)
#endif /*!_G_NO_TEMPLATES*/
#endif /*!_IOMANIP_H*/
Technical Details
Message-ID:
<b46e5056728bd01776b922a3d02ffa39@wretched.mailer.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,6c7d3c235ba569e6,start X-Google-Attributes: gid113d02,public From: charlie@uu1238.flowerslabs.com (Charles Teague) Subject: C++ Date: 1997/01/28 Message-ID: <b46e5056728bd01776b922a3d02ffa39@wretched.mailer.com> X-Deja-AN: 212753244 sender: bug-gcc-request@prep.ai.mit.edu x-gateway: wendy-fate.uu.net from bug-gcc to gnu.gcc.bug; Tue, 28 Jan 1997 10:58:01 EST newsgroups: gnu.gcc.bug