1834665 Members
2444 Online
110069 Solutions
New Discussion

Re: Function Open bug C

 
MR GROSS
Occasional Advisor

Function Open bug C

Hello,

I don't understand why the function open in languge C on Hp 10.20 serie 700 don't function.
void main()
{
int fd;

fd = open("file", O_RDONLY);
close(fd);
}
And whith goods includes.
Thanks
12 REPLIES 12
Deepak Extross
Honored Contributor

Re: Function Open bug C

What error does it report?

Add the following after your call to open()
----
if (fd < 0)
printf ("open failed with errno %d\n", errno);
----
and do a finderr on the error number.

remeber to #include .
MR GROSS
Occasional Advisor

Re: Function Open bug C

when I compile this function, this error appear:
cc: "File", line 7 / error 1588 : "O_RDONLY" undenied

yet this function function with other OS like IBM and I include good
A. Clay Stephenson
Acclaimed Contributor

Re: Function Open bug C

Hi Gross:

I hope this doesn't compile. You obviously don't have included with your good includes.
If it ain't broke, I can fix that.
Carlos Fernandez Riera
Honored Contributor

Re: Function Open bug C

#

Compile now.
unsupported
MR GROSS
Occasional Advisor

Re: Function Open bug C

But I use this include
Deepak Extross
Honored Contributor

Re: Function Open bug C

This is strange.
What does "grep O_RDONLY /usr/include/sys/fcntl.h" yield?
MR GROSS
Occasional Advisor

Re: Function Open bug C

I just try, and the sentence appear:
define O_RDONLY 000000 /*open for reading only*/
But if I replace O_RDWR the function open don't function. I think it's a bug and I want a patche please.
thanks everybody.
Carlos Fernandez Riera
Honored Contributor

Re: Function Open bug C

It seem to be a missconfiguration or bad permision on /usr/include, or something so.

/usr/include/fcntl must
#include where 0_xxx are defined.

Try swverify for ansiC package.
unsupported
Deepak Extross
Honored Contributor

Re: Function Open bug C

In that case, just replace 'O_RDONLY' with '0000000'.
Remove the #include and compile.

Quick & dirty, but it'll work for the small test program that you have. (I hope my boss doesnt see this!)
MR GROSS
Occasional Advisor

Re: Function Open bug C

I despair. I realise that nobody can help me.
thank everybody.

if you find the solution, please mail to:
eric.bocquel@sextant.thomson-csf.com
Carlos Fernandez Riera
Honored Contributor

Re: Function Open bug C

Is this your problem???

#include
#include

main()
{
int pp;

pp=open("/tmp/pp.c",0_RDONLY);
close (pp);
}
UES90201:/tmp#cc pp.c -o pp
cc: "pp.c", line 8: error 1000: Unexpected symbol: "_RDONLY".

Now:

#include
#include

main()
{
int pp;

pp=open("/tmp/pp.c",O_RDONLY);
close (pp);
}
UES90201:/tmp#cc pp.c -o pp
/usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (pp.o) was detected. The linked output may not run on a PA 1.x system.

DIFFERENCE:

0_RDONLY (zero_RDONLY) and O_RDONLY



Regards.
unsupported
Deepak Extross
Honored Contributor

Re: Function Open bug C

Full marks to Carlos for creativity! :)

Gross,
This maybe flogging a dead horse, but is it possible that you dont have or cant access /usr/include/fcntl.h?

Try
#include
instead of
#include