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

Recommended Answers

All 6 Replies

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.

There are a lot of things that VC++ 6.0 did that can no longer be done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.