"typedef int bool;" ?

K

knguyen

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
 
R

Rolf Magnus

knguyen said:
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.
 
A

Alf P. Steinbach

* 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.
 
J

Jim Langston

knguyen said:
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...).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top