This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

another newbie question about ios::noreplace and ios::nocreate


Hi 

Following is my program

***************ios_test.cpp
#include <iostream>
#include <fstream>
#include <errno.h>

using namespace std;

#define IOS_NOREPLACE ios::noreplace
#define IOS_NOCREATE ios::nocreate

int main()
{
        fstream iostrm;

        iostrm.open("ajay.txt", 666);
        if (errno == IOS_NOREPLACE)
                cout<<"hello";

        if (errno == IOS_NOCREATE)
                cout<<"hello 2";

        return 0;
}

****************

On compilation with gcc 3.2.1 on RH73, I get the following error

[ajay@linux1 stl]$ g++ ios_test.cpp 
ios_test.cpp: In function `int main()':
ios_test.cpp:15: invalid conversion from `int' to `std::_Ios_Openmode'
ios_test.cpp:15:   initializing argument 2 of `void
std::basic_fstream<_CharT, 
   _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char,
_Traits 
   = std::char_traits<char>]'
ios_test.cpp:16: `noreplace' is not a member of type
`std::basic_ios<char, 
   std::char_traits<char> >'
ios_test.cpp:19: `nocreate' is not a member of type
`std::basic_ios<char, 
   std::char_traits<char> >'


If I compile this with g++ 2.96, I do not get any error. Has there been
any change with g++ in this regard between the two releases?

-Ajay




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]