[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-cxx-dev
Subject:    Re: CXX-DEV: Problem with gcc compilation
From:       Martin Sebor <sebor () roguewave ! com>
Date:       2002-12-27 17:52:22
[Download RAW message or body]

Gagan Puri wrote:
> HI,
> 
> I have an application which is getting compiled properly with aCC. When I try
> to build my application using g++/gcc, I am getting following errors:
> 
> ./../../filelock.cpp: In member function `BOOLEAN
>    FileLock::OpenAndLockFile(const char*, int, DWORD*, int)':
> ../../../filelock.cpp:136: invalid conversion from `int' to
> `std::_Ios_Openmode
>    '
...
> 
> Problem is that in aCC, within the class ios, open_mode is an enum of
> integers. So in our code also, we are using this as an integer. So no problem
> occurs.  While opening the stream (iostrm.open(fileName, op | ios::out)), we
> are doing bitwise OR of op(integer passed as function argument) & ios::out.
> Since in case of aCC ios::out is alo an integer there is no issue.
> 
> In case of gcc/g++ , within the class ios, open_mode is an enum but not of
> integers but of type _Ios_Openmode. This is what is creating problem.
> 
> Similarly in another case there is switch case statement in which op(integer)
> is being matched with open mode which is integer in case of aCC &
> _Ios_Openmode in case of gcc/g++. This again creates probelm in gcc.
> 
> How can I get rid of these errors.

Portable programs may not assume that int is convertible to
std::ios_base::openmode (it's not required to be). While one
implementation of the C++ Standard library (e.g., aCC libstd)
may provide that conversion, others may not (e.g., GNU libstdc++
3.x).

The std::ios_base::noreplace and std::ios_base::nocreate bits
are extensions of the aCC implementation and thus relying on
them is also not portable. To eliminate the errors you will
need to remove their use from your code when compiling it with
libraries that do not provide them (e.g., via preprocessor
conditionals).

Regards
Martin
 _________________________________________________________________
 To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
    with the message UNSUBSCRIBE cxx-dev
 _________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic