Hello Friends,

I am trying to porting some pre-existing code to VC++ 2005 in Win XP environment. I have a segment of code like,

...
#include<fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
...
...
cm_iFile = open(l_chBuff,O_RDONLY|O_BINARY);
...

During compiling this file I am getting the following error message,
..\source\CRaterEDRFile.cpp(276) : error C3861: 'open': identifier not found

Pls, help me to fix the problem.

Amit

If you really want to port it to c++ then use fstream instead of those very low-level file functions. Its really not all that difficult once you understand it.

#include <fstream>
using namespace std;

int main()
{
     ifstream in(l_chBuff, ios::binary);
     // blabla
}

Thanks for your prompt reply.
But it will cause a lots of change in that code.
So is it not possible to use open function in VC++ 8.0?

Amit

>>So is it not possible to use open function in VC++ 8.0?
Its a *nix function, not supported by Microsoft compilers. Dev-C++ supports it (I just tried it), and I would expect Code::Blocks to support it too because they are both based on *nix gcc and g++ compilers.

>>But it will cause a lots of change in that code.
That's one of the dangers of writing such low-level non-standard code. Your program isn't very portable to other systems and compilers.

>>So is it not possible to use open function in VC++ 8.0?
Its a *nix function, not supported by Microsoft compilers. Dev-C++ supports it (I just tried it), and I would expect Code::Blocks to support it too because they are both based on *nix gcc and g++ compilers.

But it was complied fine with VC6.0.

This article has been dead for over six months. Start a new discussion instead.