By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,849 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,849 IT Pros & Developers. It's quick & easy.

"typedef int bool;" ?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
* 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

P: n/a
"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.