Thread View: comp.sys.sgi.apps
12 messages
12 total messages
Started by James Adams
Tue, 09 Apr 1996 20:01
SGI's C++ compiler and the boolean type
Author: James Adams
Date: Tue, 09 Apr 1996 20:01
Date: Tue, 09 Apr 1996 20:01
34 lines
1636 bytes
1636 bytes
Hello, I have begun using SGI's C++ compiler (Translator 4.0) since I want to use their CASEVision debugger. I have previously used g++ to do my compilation, and it correctly interpreted the "bool" type without any problems. However now that I am using SGI's compiler I get all kinds of compiler errors whenever it encounters "bool", "true", or "false" in my codes. The only workaround I've been able to come up with is to include the following lines in my header file: typedef int bool; #define true 1 #define false 0 Is there something that I'm missing here, such as compiler flags or include files ? Is this a case of SGI dropping the ball by not including support for a standard type ? The command I'm using to compile with is CC -g -o plusfilt main.cpp frame.cpp buffer.cpp options.cpp list.cpp -lm Thanks for any suggestions or insight ! -James -- --------------------------------------------------------------------------- James Adams Email: jadams@ucar.edu National Center for Atmospheric Research Phone: (303) 497-1356 Boulder, Colorado Fax: (303) 497-1348 WWW: http://www.cgd.ucar.edu/ccr/jadams/home.html
Re: SGI's C++ compiler and the boolean type
Author: Kent Sandvik
Date: Wed, 10 Apr 1996 00:51
Date: Wed, 10 Apr 1996 00:51
33 lines
1960 bytes
1960 bytes
In article <4kefm7$oao@ncar.ucar.edu>,
jadams@sage.cgd.ucar.edu (James Adams) wrote:
> I have begun using SGI's C++ compiler (Translator 4.0) since
>I want to use their CASEVision debugger. I have previously used g++
>to do my compilation, and it correctly interpreted the "bool" type
>without any problems. However now that I am using SGI's compiler I
>get all kinds of compiler errors whenever it encounters "bool", "true",
>or "false" in my codes. The only workaround I've been able to come up
>with is to include the following lines in my header file:
>
>typedef int bool;
>#define true 1
>#define false 0
bool is a fairly new ANSI C++ draft proposal keyword; I wish someone would
finally finish the ANSI C++ specs, seems to drag on and on...
Anyway, the keyword is supported starting with the 6.2 compilers, chapter 3
of the forthcoming 6.2 release notes have information about what's new,
including support for bool and wchar_t types. Meanwhile you could use the
trick you are using above.
Note that when bool is used in the 6.2 compilers, true and false will be
reserved keywords. The compiler will also then predefine a macro called
_BOOL, so you could use this label as well.
--Kent
Kent Sandvik, Silicon Graphics, Inc. Member of Technical Staff
Email: sandvik@sgi.com Phone: +1 415 933-6417
http://reality.sgi.com/sandvik/ (sgi http:/kent.engr/)
"May all developers be happy."
Re: SGI's C++ compiler and the boolean type
Author: Arthur Hagen
Date: Wed, 10 Apr 1996 11:36
Date: Wed, 10 Apr 1996 11:36
22 lines
1100 bytes
1100 bytes
In article <4kefm7$oao@ncar.ucar.edu>, jadams@sage.cgd.ucar.edu writes: ... > get all kinds of compiler errors whenever it encounters "bool", "true", > or "false" in my codes. The only workaround I've been able to come up > with is to include the following lines in my header file: > > typedef int bool; > #define true 1 > #define false 0 And some argue that true should be -1, because then bitwise not works: ~(true = -1) == (false = 0) ~(false = 0) == (true = -1) -- Arthur Hagen, Sysadmin, Interactive Design Business: art@design.idg.no / http://www.design.idg.no/ Personal: art@mother.idg.no / http://mother.idg.no/~art/ Flames: billg@microsoft.com / http://127.0.0.1/
Re: SGI's C++ compiler and the boolean type
Author: Andrew Koenig
Date: Wed, 10 Apr 1996 13:08
Date: Wed, 10 Apr 1996 13:08
11 lines
661 bytes
661 bytes
In article <4kg6fv$h7k@nic.ftns.no> art@mother.idg.no writes: > And some argue that true should be -1, because then bitwise not works: > ~(true = -1) == (false = 0) > ~(false = 0) == (true = -1) ... and (3<4)==true fails. -- --Andrew Koenig ark@research.att.com
Re: SGI's C++ compiler and the boolean type
Author: J. Karl Armstrong
Date: Wed, 10 Apr 1996 20:45
Date: Wed, 10 Apr 1996 20:45
14 lines
1068 bytes
1068 bytes
In article <4kefm7$oao@ncar.ucar.edu>, jadams@sage.cgd.ucar.edu wrote: > Is there something that I'm missing here, such as compiler >flags or include files ? Is this a case of SGI dropping the ball by >not including support for a standard type ? To be fair, 'bool' is _not_ a standard type; it's a _proposed_ standard type. There's a difference. -- J. Karl Armstrong Computing Devices Int. jonathan.k.armstrong@cdev.com 6041 S. Syracuse Way, Ste 300 (303) 779-7702 Greenwood Villiage, CO, 80111 (303) 779-7704 (fax)
Re: SGI's C++ compiler and the boolean type
Author: Chung-chieh Shan
Date: Wed, 10 Apr 1996 23:04
Date: Wed, 10 Apr 1996 23:04
14 lines
1073 bytes
1073 bytes
> And some argue that true should be -1, because then bitwise not works: > ~(true = -1) == (false = 0) > ~(false = 0) == (true = -1) According to the proposed standard, true is implicitly casted from bool to the integer 1. Nonzero integers are implicitly casted from int to the bool true. Funny nobody has written an implementation of bool. (AFAIK) -- blue | Chung-chieh Shan (Ken) | Life is a sexually transmitted () | ccshan@fas.harvard.edu | math too is a terminal representation /\ | Finger for PGP key | game. disease. of Quality.
Re: SGI's C++ compiler and the boolean type
Author: David Wald
Date: Thu, 11 Apr 1996 14:59
Date: Thu, 11 Apr 1996 14:59
25 lines
1608 bytes
1608 bytes
In article <4khepk$8k1@decaxp.HARVARD.EDU> ccshan@scws44.harvard.edu
(Chung-chieh Shan) writes:
>According to the proposed standard, true is implicitly casted from
>bool to the integer 1. Nonzero integers are implicitly casted from
>int to the bool true.
>
>Funny nobody has written an implementation of bool. (AFAIK)
That may be because you can't write a class that behaves like the
draft standard bool type. In the draft standard, all the standard
boolean operators actually return a bool type, and there's no way to
produce that effect with a user-defined type. E.g.,
int f(int) { return 1; }
int f(bool) { return 0; }
int distinguish() { return f( 0 == 1 ); }
No user-level definition of bool will make distinguish() return 0, as
it must in the draft standard.
-David
--
============================================================================
David Wald http://theory.lcs.mit.edu/~wald/ wald@theory.lcs.mit.edu
============================================================================
Re: SGI's C++ compiler and the boolean type
Author: Scott Byer
Date: Fri, 12 Apr 1996 17:21
Date: Fri, 12 Apr 1996 17:21
30 lines
2267 bytes
2267 bytes
J Karl Armstrong writes: J> In article <4kefm7$oao@ncar.ucar.edu>, jadams@sage.cgd.ucar.edu wrote: >> Is there something that I'm missing here, such as compiler flags or >> include files ? Is this a case of SGI dropping the ball by not including >> support for a standard type ? J> To be fair, 'bool' is _not_ a standard type; it's a _proposed_ standard J> type. There's a difference. The standard has been reasonably stable for a year now. All the other compilers I've got all have at least an _option_ for compiling at the standard's level. The ARM is simply too weak to use as a basis for real world code, and when dealing with multiple compilers you have to have something to fall back to in order to arbitrate compiler differences, and that's the proposed ANSI C++ standard. ANSI has done a remarkable job of taking a language that seems to have been cobbled together more than designed, and making it at least tolerable. IMO, SGI has dropped the ball in not providing at least the _option_ - hey, let me hang myself if I program to a proposed standard that changes out from underneath me, but _let_me_choose_. -- Scott Byer, Unix Photoshop Project Lead mailto:byer@mv.us.adobe.com Adobe Systems Incorporated These are my opinions, and 1585 Charleston Road, P.O. Box 7900 do not necessarily reflect Mountain View, CA 94039-7900 the opinions of my employer. === ===
Re: SGI's C++ compiler and the boolean type
Author: David B.Anderson
Date: Fri, 12 Apr 1996 22:03
Date: Fri, 12 Apr 1996 22:03
20 lines
1299 bytes
1299 bytes
In article <psrattcq9h.fsf@birch.mv.us.adobe.com>, Scott Byer <byer@mv.us.adobe.com> wrote: > >J Karl Armstrong writes: >J> In article <4kefm7$oao@ncar.ucar.edu>, jadams@sage.cgd.ucar.edu wrote: [looking for bool type ] >>> Is there something that I'm missing here, such as compiler flags or >J> To be fair, 'bool' is _not_ a standard type; it's a _proposed_ standard >J> type. There's a difference. At the risk of repetition, 'bool' *is* in the IRIX6.2 C++ product for -n32 and -64 compiles (not -32). 6.2 was just released. Exception handling will be released for 6.2 c++ but has not been released yet. Regards, [ David B. Anderson (415)933-4263 davea@sgi.com ] [ Visualize Whirled Peas ]
Re: SGI's C++ compiler and the boolean type
Author: Scott Nelson
Date: Fri, 19 Apr 1996 03:08
Date: Fri, 19 Apr 1996 03:08
18 lines
914 bytes
914 bytes
Arthur Hagen wrote: > > > > > typedef int bool; > > #define true 1 > > #define false 0 > > And some argue that true should be -1, because then bitwise not works: > We use the following. It's safe on all platforms: #define FALSE 0 #define TRUE (!0) Let the built-in ! operator determine what TRUE really is. Scott Nelson
Re: SGI's C++ compiler and the boolean type
Author: Kevin Cline
Date: Fri, 19 Apr 1996 15:04
Date: Fri, 19 Apr 1996 15:04
33 lines
1145 bytes
1145 bytes
In article <31770390.2781@llnl.gov>, Scott Nelson <nelson18@llnl.gov> wrote: >Arthur Hagen wrote: >> >> > >> > typedef int bool; >> > #define true 1 >> > #define false 0 >> >> And some argue that true should be -1, because then bitwise not works: >> > >We use the following. It's safe on all platforms: > >#define FALSE 0 >#define TRUE (!0) > >Let the built-in ! operator determine what TRUE really is. > >Scott Nelson The real lesson here is to write if (x) or if (!x) instead of if (x == true) and if (x == false) Then it doesn't matter what the value of true is, as long as it is not zero. -- Kevin Cline
Re: SGI's C++ compiler and the boolean type
Author: Mike Rubenstein
Date: Sat, 20 Apr 1996 02:37
Date: Sat, 20 Apr 1996 02:37
28 lines
1062 bytes
1062 bytes
Scott Nelson <nelson18@llnl.gov> wrote: > Arthur Hagen wrote: > > > > > > > > typedef int bool; > > > #define true 1 > > > #define false 0 > > > > And some argue that true should be -1, because then bitwise not works: > > > > We use the following. It's safe on all platforms: > > #define FALSE 0 > #define TRUE (!0) > > Let the built-in ! operator determine what TRUE really is. How is that safer than #define FALSE 0 #define TRUE 1 !0 is guaranteed to be 1 in both C and C++. Michael M Rubenstein
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads