Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

compilation error-aCC [ bool int confusion ]

SOLVED
Go to Solution
Occasional Contributor

compilation error-aCC [ bool int confusion ]

Hello,
I am currently wrestling with a compiler error thrown while compiling a relative archaic piece of application code with aCC( A.03.70). The code compiles fine with a previous aCC(A.03.25).Platform HP-UX 11.11 PA-RISC

Error

526: "/opt/aCC/include/iostream/iostream.h", line 406 # Class member function declaration is indistinguishable from "istream
&istream::operator >>(int &)" already declared at ["/opt/aCC/include/iostream/iostream.h", line 384].
istream& operator>>(int&);
^^
Error 526: "/opt/aCC/include/iostream/iostream.h", line 563 # Class member function declaration is indistinguishable from "ostream
&ostream::operator <<(int)" already declared at ["/opt/aCC/include/iostream/iostream.h", line 547].
ostream& operator<<(bool b) { return *this << (int)b ; }
^^
Error 445: "/opt/aCC/include/iostream/iostream.h", line 563 # Cannot recover from earlier errors.
ostream& operator<<(bool b) { return *this << (int)b ; }



in iostream.h
line 406 -> istream& operator>>(int&);
line 384 -> istream& operator>>(bool&);


I am using the following compiler options
+Z -D_REENTRANT -AP -D_HPUX_SOURCE -O +DS2.0 +DA2.0 -z -D_REENTRANT -D_THREAD_SAFE -D__HPACC_THREAD_SAFE_RB_TREE -DRWSTD_MULTI_THREAD -DRW_MULTI_THREAD

I would prefer the default -AP option rather than -AA .

Can anybody provide pointers to resolve this.

Thanks
Vinay
1 ACCEPTED SOLUTIONS

Re: compilation error-aCC [ bool int confusion ]

Use the preprocessor options -E -.i to get the preprocessed ouput of your source file. Find whether you have two instances of istream &istream::operator >>(int &). It proves that you (directly or indirectly) have defined a macro bool to be an int.

Since A.03.70 does not support any options like -dM you could use the following technique to find where you have defined the macro bool (incase it could not be find by simple grep). Include #define bool catch_bool_macro. Compile your source file with the original command line. You should get a warning with the location where the macro is (re)defined.

By the way, I see that if I define bool to an int I get the same error with A.03.25 as well like A.03.70.
4 REPLIES
Acclaimed Contributor Acclaimed Contributor

Re: compilation error-aCC [ bool int confusion ]

>in iostream.h
line 406 -> istream& operator>>(int&);
line 384 -> istream& operator>>(bool&);

You probably have an evil macro that defines bool as int.

>-D_REENTRANT -D_THREAD_SAFE -DRWSTD_MULTI_THREAD -DRW_MULTI_THREAD

You can replace these by just -mt.

Re: compilation error-aCC [ bool int confusion ]

Use the preprocessor options -E -.i to get the preprocessed ouput of your source file. Find whether you have two instances of istream &istream::operator >>(int &). It proves that you (directly or indirectly) have defined a macro bool to be an int.

Since A.03.70 does not support any options like -dM you could use the following technique to find where you have defined the macro bool (incase it could not be find by simple grep). Include #define bool catch_bool_macro. Compile your source file with the original command line. You should get a warning with the location where the macro is (re)defined.

By the way, I see that if I define bool to an int I get the same error with A.03.25 as well like A.03.70.
Acclaimed Contributor Acclaimed Contributor

Re: compilation error-aCC [ bool int confusion ]

[ Edited ]

>Kannan: Since A.03.70 does not support any options like -dM

Instead you use cpp.ansi:
... -E -.i +legacy_cpp -Wp,-C,-G

Then look for bool.

Highlighted
Occasional Contributor

Re: compilation error-aCC [ bool int confusion ]

Thanks Kannan and Dennis for your valuable feedback. The issue was exactly as you'll mentioned. A redefinition of bool which was invoked in a "#ifndef HPUX" statement.
Once I provided the compiler option -DHPUX ,the redundancy was not included and compiled smoothly.

Extra thanks to Kannan for helping hunt down the error.

-Vinay