Error: Symbol O_RDONLY is not defined

Hi,

Could you advice me how can I make it work open() function with gcc 4.1.2?

#include <fnctl.h>
int fdl
fd = open(“test.dat”, O_RDONLY);
close(fd);

then I get error “O_RDONLY is not defined”. This works for older glib such as gcc 3.4.6.
Is there good way of make open() function work with gcc 4.1.2?
I would like to stick with open function rather than fopen function because it requires me
further modifications into codes.

thanks

use one of the 2 variants below

Rene

#include <stdio.h> void fn() { FILE *fd = fopen("test.dat","r"); if (fd)fclose(fd); }
or

#include "Riostream.h" void fn2() { ifstream in; in.open(Form("test.dat"); in.close(); }

Actually I have to modify present read statements if I use fopen() function.

#include <fnctl.h>
int fd, data;
fd = open(“test.dat”, O_RDONLY);
while ( read(fd,&data, 4) > 0 ) {

}
close(fd);

What is the best way to translate read(fd, &data, 4) to be substituted by, say
fread() or fscanf()?

Instead of

[code]#include <fnctl.h>
int fd, data;
fd = open(“test.dat”, O_RDONLY);
while ( read(fd,&data, 4) > 0 ) {

}
close(fd);[/code]
do

[code]#include <stdio.h>
FILE *fd = fopen(“test.dat”,“r”);

const int bufferSize = 1024;
int buffer[bufferSize];
int sz;
while((sz=fread(buffer,4,bufferSize,fd)) {

}
fclose(fd);
[/code]
Rene