469,085 Members | 1,045 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,085 developers. It's quick & easy.

"typedef int bool;" ?

Hello,

I was trying to compile the source code from "Design Patterns:
Elements of Reusable Object-Oriented Software", which can be obtained
from here ftp://st.cs.uiuc.edu/pub/patterns/dpcat/DPCPP.zip

The compiler gaves me an error at line 13 in Foundation.H - "typedef
int bool;" . In this case, I was trying to compile maze.c in folder C+
+

Foundation.H:13: error: redeclaration of C++ built-in type `bool'

Would anyone please explain this error for me? It also seems strange
to me about the line "typedef int bool;" as well, what is it trying to
accomplish?

Many thanks

Mar 21 '07 #1
3 16062
knguyen wrote:
Hello,

I was trying to compile the source code from "Design Patterns:
Elements of Reusable Object-Oriented Software", which can be obtained
from here ftp://st.cs.uiuc.edu/pub/patterns/dpcat/DPCPP.zip

The compiler gaves me an error at line 13 in Foundation.H - "typedef
int bool;" . In this case, I was trying to compile maze.c in folder C+
+

Foundation.H:13: error: redeclaration of C++ built-in type `bool'

Would anyone please explain this error for me?
It's pretty much self-explanatory. bool is a built-in type in C++, so you
can't use it as a typedef name.
It also seems strange to me about the line "typedef int bool;" as well,
what is it trying to accomplish?
Seems like it's for a very old C++ compiler that didn't support the bool
type yet.

Mar 22 '07 #2
* knguyen:
>
I was trying to compile the source code from "Design Patterns:
Elements of Reusable Object-Oriented Software", which can be obtained
from here ftp://st.cs.uiuc.edu/pub/patterns/dpcat/DPCPP.zip

The compiler gaves me an error at line 13 in Foundation.H - "typedef
int bool;" . In this case, I was trying to compile maze.c in folder C+
+

Foundation.H:13: error: redeclaration of C++ built-in type `bool'

Would anyone please explain this error for me? It also seems strange
to me about the line "typedef int bool;" as well, what is it trying to
accomplish?
Before C99 C didn't have a 'bool' type. It seems you're trying to
compile old C as C++. Try to compile C as C.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 22 '07 #3
"knguyen" <ng************@gmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
Hello,

I was trying to compile the source code from "Design Patterns:
Elements of Reusable Object-Oriented Software", which can be obtained
from here ftp://st.cs.uiuc.edu/pub/patterns/dpcat/DPCPP.zip

The compiler gaves me an error at line 13 in Foundation.H - "typedef
int bool;" . In this case, I was trying to compile maze.c in folder C+
+

Foundation.H:13: error: redeclaration of C++ built-in type `bool'

Would anyone please explain this error for me? It also seems strange
to me about the line "typedef int bool;" as well, what is it trying to
accomplish?

Many thanks
Look at line 13 of Foundation.H. It will have the text "bool" as a
structure, or class or define or something. C++ now has a built in type
bool that is true or false. First look at how bool is being used, and
determine if it will work with the built in type bool. If it looks
reasonalbe then you should be able to just comment out the declaration of
bool and fix the compile time errors (it may be setting TRUE and FALSE
instead of true and false, etc...).
Mar 22 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Fao | last post: by
6 posts views Thread by hercules | last post: by
1 post views Thread by Thomas Barnet-Lamb | last post: by
reply views Thread by Gary | last post: by
134 posts views Thread by jacob navia | last post: by
8 posts views Thread by Mohammad Omer Nasir | last post: by
8 posts views Thread by cman | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.