types of 'Open' command

P

prabhu.pravin

Hi ,
in some code i observe that files are opened using 'open'
command, but some code uses '_open' call, what is the difference if
any, i have seen a lot of functions called using '_' as first
character, i wanted to know what they signify.

thanks,
pravin
 
I

Ico

Hi ,
in some code i observe that files are opened using 'open'
command, but some code uses '_open' call, what is the difference if
any, i have seen a lot of functions called using '_' as first
character, i wanted to know what they signify.

On POSIX-compliant systems, open() is a function to open and/or create a
file. The _open() function could be anything platform-specific; check
the documentation of your operating system for more info.
 
K

Keith Thompson

in some code i observe that files are opened using 'open'
command, but some code uses '_open' call, what is the difference if
any, i have seen a lot of functions called using '_' as first
character, i wanted to know what they signify.

Neither "open" nor "_open" is defined by the C standard.

<OT>POSIX defined an open() function. I don't know about _open.
Try a newsgroup that deals with whatever system you're using.</OT>
 
C

CBFalconer

in some code i observe that files are opened using 'open'
command, but some code uses '_open' call, what is the difference
if any, i have seen a lot of functions called using '_' as first
character, i wanted to know what they signify.

They signify that the programmer was ignorant. In general all
identifiers starting with '_' are reserved for the implementation.
Standard C does not have any such function as open or _open.
 
E

Eric Sosman

CBFalconer said:
They signify that the programmer was ignorant.

Balderdash. They may merely signify that the programmer
chose to use APIs and interfaces outside the realm of the C
Standard. That is to say, the programmer was employing *more*
knowledge than the C Standard imparts, and is therefore the
very opposite of ignorant.

Now, it is possible that the programmer did not actually
need the beyond-C capabilities he wound up using, that his
choice to use them was ill-informed. If so, the case for
ignorance might be made. But since you and I know absolutely
zero, zilch, nada about the situation confronting that anonymous
programmer, we are in no position to make such rash judgements.
Lighten up!
 
B

Banfa

Keith said:
Neither "open" nor "_open" is defined by the C standard.

<OT>POSIX defined an open() function. I don't know about _open.
Try a newsgroup that deals with whatever system you're using.</OT>

When I started programming 15 years ago we used _open, _read, _write
and _close instead of any standard function. They where the
implementation defined file handling functions for DOS in our case.

While a realise now what the difference is between say fopen and _open
(standard and implementation defined) I am still not sure why we chose
to use _open rather than fopen, although I suspect that my boss figured
that if fopen had, ultimately, to call _open that we might as well cut
out the middleman and call _open directly thus saving on processor
time.

Of course this would make the code non-portable but since we were
writing programs to run on Windows 2 at the time I suspect this was not
a huge consideration.
 
N

Nelu

CBFalconer said:
They signify that the programmer was ignorant. In general all
identifiers starting with '_' are reserved for the implementation.
Standard C does not have any such function as open or _open.
I think that that function is Microsoft's attempt at writing something
somewhat POSIX compliant. They have _open and _wopen which do the same
thing they do under UNIX (_wopen is for wchar_t). You even need to
include the same headers to use them.
 
R

Richard Tobin

Nelu said:
I think that that function is Microsoft's attempt at writing something
somewhat POSIX compliant. They have _open and _wopen which do the same
thing they do under UNIX (_wopen is for wchar_t). You even need to
include the same headers to use them.

But Unix doesn't have functions called _open or _wopen.

-- Richard
 
N

Nelu

But Unix doesn't have functions called _open or _wopen.
That's why I said "something somewhat POSIX compliant". :)
Windows _open does the same thing that UNIX open does.
Were you expecting Microsoft to actually play nice about this? :)
 
C

CBFalconer

Richard said:
But Unix doesn't have functions called _open or _wopen.

And Microsoft never attempts to comply with standards, they attempt
to sabotage them. Portability away from anything Microsoftian is
an evil concept to them.
 
K

Keith Thompson

CBFalconer said:
And Microsoft never attempts to comply with standards, they attempt
to sabotage them. Portability away from anything Microsoftian is
an evil concept to them.

That's a considerable overstatement.
 
R

Richard Tobin

CBFalconer said:
And Microsoft never attempts to comply with standards, they attempt
to sabotage them.

This may be true, but I have been on standards committees with people
from Microsoft and they have generally been very reasonable. The most
obvious negative tendency I have noticed works in a rather different
way: Microsoft is happy for standards to be many and complicated,
because they are big enough to implement anything,

-- Richard
 
N

Nelu

This may be true, but I have been on standards committees with people
from Microsoft and they have generally been very reasonable. The most
obvious negative tendency I have noticed works in a rather different
way: Microsoft is happy for standards to be many and complicated,
because they are big enough to implement anything,

It's one thing to believe that you can implement anything and a
totally different thing to implement everything properly.
 
C

CBFalconer

Richard said:
This may be true, but I have been on standards committees with people
from Microsoft and they have generally been very reasonable. The most
obvious negative tendency I have noticed works in a rather different
way: Microsoft is happy for standards to be many and complicated,
because they are big enough to implement anything,

I'm sure that's true. The people who do the work are probably
quite reasonable. But when it comes to corporate policy and the
great god the almighty buck, the attitude is quite different. How
else do you explain the mangling of html standards, for example,
and the refusal to make any attempt to implement C99?

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs)
<http://clc-wiki.net> (C-info)
 
A

Andrew Poelstra

I'm sure that's true. The people who do the work are probably
quite reasonable. But when it comes to corporate policy and the
great god the almighty buck, the attitude is quite different. How
else do you explain the mangling of html standards, for example,
and the refusal to make any attempt to implement C99?

I'm not sure that it's possible for sheer red tape and incompetence to
explain the HTML butchering. There's something far more sinister
behind there; MS has repeatedly attempted to take over the Internet.

I've always wondered why people work for Microsoft. It used to be a great
company, but now it seems to simply be a morale drain. Working for MS is
enough of a resume boost that employees could get whatever job they wanted.
 
R

Richard Bos

This may be true, but I have been on standards committees with people
from Microsoft and they have generally been very reasonable.

That's as may be, but their actual software rarely bears this out.

Richard
 
C

Charles Richmond

CBFalconer said:
And Microsoft never attempts to comply with standards, they attempt
to sabotage them. Portability away from anything Microsoftian is
an evil concept to them.
ISTM that standards would be odious to Microsoft. Evil is their business.
 
M

Mark McIntyre

How
else do you explain the mangling of html standards, for example,

Because MS saw a need for more sophisticated web page functionality
and wanted to corner the market. Just a guess of course.
and the refusal to make any attempt to implement C99?

Because MS saw no market need for most of the features, because no
large clients were asking and their combined C and C++ implementation
handled the simple stuff already. Again, just a guess.

I'm no MS apologist, but I don't think its sensible to blame a company
for taking commercial decisions. Since when did they become a charity?
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top