stdio.h ?

  • Thread starter \(ProteanThread\)
  • Start date
M

Maxim S. Shatskih

Makes sense (but microsoft usually never follows the rules anyways)
They are trying to do so more and more, but they
botched many things in the past and are stuck with
them.

Microsoft has both standard features and proprietary features, and the
documentation does not says what is standard and portable and what is
proprietary. For instance, fopen(name, "wb") is not documented as being
Windows-only.

This policy is surely to simplify porting the code to Windows, but not from
Windows :)

As about "MS not following the standards" if we are speaking about languages -
then they have some STL implementation different a bit from the SGI's STL.
People who were porting the heavy-use-STL code from Linux to Windows had
problems due to this. I think that probably MS uses the obsolete STL standard.

Anyway this is C++ and not C.

BTW - when MS had their Java toolkit, they strictly divided "Sun's
documentation" from "MS's documentation". If you used features from Sun's
documentation only - then the Java code was portable and multi-platform.

Nevertheless, among MS-only extensions to Java there were the analogs of
LoadLibrary/GetProcAddress (dlopen() and dlsym() in UNIXen), and MS recommended
them for use to call Windows-only native machine code from Java code. This is
what caused Sun to become outrageous and starting the lawsuit.

For now, they have C# and .NET with a similar feature called "pinvoke". I dunno
what is better - Java or .NET. From what I've heard on people working with
these tools, .NET designers were taught by Java's weak places, and thus C#/.NET
is better then Java - they have removed/reworked some things which were badly
designed in Java.
 
C

Clark S. Cox III

You might want to read chapter 7 and specifically 7.19
:)

I have. What's your point?

Nothing in the standard says that stdio.h actually has to exist, or
that it actually has to be a file on disk, containing C code. You only
know that by typing:

#include <stdio.h>

in C source code, you will get declarations of several functions,
macros and types.
 
M

Michael Mair

Maxim said:
Microsoft has both standard features and proprietary features, and the
documentation does not says what is standard and portable and what is
proprietary. For instance, fopen(name, "wb") is not documented as being
Windows-only.

I am glad to hear this -- because it would be wrong.
'w' and 'b' are both standard C, as is "wb".
Do you mean "wt" (instead of standard "w")?

Cheers
Michael
 
M

Mark McIntyre

I have. What's your point?

it defines whats in stdio.h.
Nothing in the standard says that stdio.h actually has to exist, or
that it actually has to be a file on disk, containing C code.

I've never said that it did - in fact if you read my comments elsethread you'll
see I said the same thing. I don't see that as remotely relevant tho.

The standard lists what is defined in stdio.h. Whether its "in" as in "inside
some file" or "in" as in "in pixie dust and copied into your translation unit
during phase x of compilation" is highly immaterial.
 
J

Jonathan Mcdougall

Maxim said:
Microsoft has both standard features and proprietary features, and the
documentation does not says what is standard and portable and what is
proprietary. For instance, fopen(name, "wb") is not documented as being
Windows-only.

I think "wb" is standard, but I may be mistaken.
As about "MS not following the standards" if we are speaking about languages -
then they have some STL implementation different a bit from the SGI's STL.
People who were porting the heavy-use-STL code from Linux to Windows had
problems due to this. I think that probably MS uses the obsolete STL standard.

Prior to Visual C++ 7.0, the support for templates was very scarce and
the STL is all about templates, which made the standard library quite
non-compliant. From 7.1, it gets quite close to full compliance.


Jonathan
 
C

Clark S. Cox III

I've never said that it did - in fact if you read my comments
elsethread you'll see I said the same thing. I don't see that as
remotely relevant tho.

Then I misinterpreted you, sorry.
 
M

Maxim S. Shatskih

I am glad to hear this -- because it would be wrong.
'w' and 'b' are both standard C, as is "wb".

I saw Linux failing fopen() if "wb" is specified, so I considered this to be
Microsoftism.

It was old ago in 2000 though.
 
M

Maxim S. Shatskih

Prior to Visual C++ 7.0

Is it Visual Studio 2003?

Sorry, I only use the Windows DDK to build and eVC++ 4.0 as pure text editor
(similar to VC++ 6 aka VS98 but newer a bit). So, I don't know much about newer
Visual Studios. MS has different versioning for Visual Studio product, for
Visual C++ product and for CL compiler itself.

Also - can you name some template-related C++ features absent in VC6 aka VS98
aka CL 12.x?
 
J

Jonathan Mcdougall

Maxim said:
Is it Visual Studio 2003?

7.0 is .NET 2002 and 7.1 is .NET 2003.
Also - can you name some template-related C++ features absent in VC6 aka VS98
aka CL 12.x?

I am not sure whether these features appeared in 7.0 or 7.1, but here
some I can think of right now:

.. partial specialization
.. argument-dependent lookup (ADL)
.. template template parameters
.. out-of-class member template definitions

Plus, many bugs ("internal compiler error") have been fixed and
conformance to the standard is quite correct. It compiles Boost and
Loki with no problem, while 6.0 was barely able to compile its own
standard library.


Jonathan
 
C

CBFalconer

Maxim S. Shatskih said:
I saw Linux failing fopen() if "wb" is specified, so I considered
this to be Microsoftism.
From N869:

7.19.5.3 The fopen function

Synopsis

[#1]

#include <stdio.h>
FILE *fopen(const char * filename,
const char * mode);

Description

[#2] The fopen function opens the file whose name is the
string pointed to by filename, and associates a stream with
it.

[#3] The argument mode points to a string. If the string is
one of the following, the file is open in the indicated
mode. Otherwise, the behavior is undefined.214)

r open text file for reading
w truncate to zero length or create text file for
writing
a append; open or create text file for writing at
end-of-file
rb open binary file for reading
wb truncate to zero length or create binary file for
writing
ab append; open or create binary file for writing at
end-of-file
r+ open text file for update (reading and writing)
w+ truncate to zero length or create text file for
update
a+ append; open or create text file for update,
writing at end-of-file
r+b or rb+ open binary file for update (reading and writing)
w+b or wb+ truncate to zero length or create binary file
for update
a+b or ab+ append; open or create binary file for update,
writing at end-of-file
 
D

Dave Thompson

On 8 Mar 2005 23:08:10 GMT, (e-mail address removed)-cnrc.gc.ca (Walter
Roberson) wrote:
If you are trying to find a language that says, "It's okay to
redefine the system library routines," then the only one I can think
of at the moment is Forth. LISP and Scheme too maybe.

Actually in Forth everything is a 'word' (dictionary entry) including
things that other languages (including C) consider 'primitive' like
add, dereference, IF-ELSE, etc., and you can redefine any word.
Similarly in LISP everything except for a few syntactic forms, and
AIUI in Scheme everything period, is just a named function, and (all
such) can be redefined.

Fortran allows you to (re)use the names of 'intrinsic' (library)
routines for your own subprograms if you explicitly declare them
EXTERNAL as opposed to INTRINSIC, and PL/I similarly if you declare
them ENTRY rather than BUILTIN, but this can not affect things like +
and DO. Fortran>=90, like C++, allows you to overload for user-defined
types the builtin computational operators and assignment (which unlike
C++ is not just an operator) but you cannot override the standard
meanings for builtin/basic types. F9X also allows you to create
entirely new operators, which you must of course define for all cases
(types) you want to handle.

Ada has hierarchical namespaces and you can use in your own
namespace(s) the same names that the standard routines use in the
standard namespaces, but this does not replace or even completely hide
the standard ones.


- David.Thompson1 at worldnet.att.net
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top