what'd the difference between STDIN and Keyboard buffer ?

P

pete

At the point in the thread when you wrote that,
were you aware of the part of the standard which you quoted below,
where stdin is defined as a pointer expression ?
.. which represents a stream.


It's a macro that expands to a pointer to 'FILE'

It doesn't have to be a macro.
I didn't say that stdin is or is not a stream.

Who said you did?
I would say that the expression 'stdin' *denotes* a stream,

That's one example of loose terminology.
Your quoted standard text would look pretty funny
if the standard were consistent with that usage:
which led to my 'loose' term 'pointer to a stream'.

Loose terminology in the C standard was my point.
The meaning of stdin,
is the topic of the subject line of this thread.
7.19 Input/output <stdio.h>

7.19.1 Introduction

1 The header <stdio.h> declares three types, several macros,
and many functions for performing input and output.

2 The types declared are ...

[...]

FILE

which is an object type capable of recording all the
information needed to control a stream, including its
file position indicator, a pointer to its associated
buffer (if any), an error indicator that records whether
a read/write error has occurred, and an end-of-file
indicator that records whether the end of the file has
been reached

[...]

3 The macros are ...

[...]

stderr
stdin
stdout

which are expressions of type "pointer to FILE" that
point to the FILE objects associated, respectively,
with the standard error, input, and output streams.

Now there,
the standard is plainly describing the relationship
between stdin and the standard input stream,
and they are two different things.
I don't think calling a 'FILE' an abstraction of a stream
is inaccurate.

If you want to call that "an abstraction",
(defining two seperate things and then calling one of them
by the name of the other)
then abstraction doesn't belong in the standard,
and there is no other abstraction like that
anywhere else in the standard.
But I suppose we're only mincing words here. :)

My answer to OP's question in the subject line is:
A keyboard is one kind file commonly associated with the
standard input stream.
stdin is a pointer expression, pointing to an object
associated with the standard input stream.
 
C

Chris Torek

It [stdin] doesn't have to be a macro.

Actually, it *does* have to be a macro, for no good reason other
than "the standard's wording accidentally says so". You requoted
the text yourself here:
3 The macros are ...
[...]
stderr
stdin
stdout

Because this says "macros", a <stdio.h> that uses:

extern FILE *stdin, *stdout, *stderr;

(as at least one GNU-library header does) must also contain:

#define stdin stdin
#define stdout stdout
#define stderr stderr

simply so that a "compiler conformance testing suite" that uses:

#include <stdio.h>

#ifndef stdin
# error stdin is not a macro
#endif

will not fail.

(Everything else you wrote appears fine to me, and there is no good
REASON for the above as far as I know -- it just happens to be "one
of those things", as they say.)
 
P

pete

Chris said:
It [stdin] doesn't have to be a macro.

Actually, it *does* have to be a macro, for no good reason other
than "the standard's wording accidentally says so". You requoted
the text yourself here:
3 The macros are ...
[...]
stderr
stdin
stdout

Because this says "macros", a <stdio.h> that uses:

extern FILE *stdin, *stdout, *stderr;

(as at least one GNU-library header does) must also contain:

#define stdin stdin
#define stdout stdout
#define stderr stderr

simply so that a "compiler conformance testing suite" that uses:

#include <stdio.h>

#ifndef stdin
# error stdin is not a macro
#endif

will not fail.

(Everything else you wrote appears fine to me, and there is no good
REASON for the above as far as I know -- it just happens to be "one
of those things", as they say.)

Thank you.
 
L

lawrence.jones

Chris Torek said:
Actually, it *does* have to be a macro, for no good reason other
than "the standard's wording accidentally says so".

Indeed. There are some other things (most notably errno) that are
allowed to be either macros or identifiers with external linkage, but we
neglected to allow that license for stdin and friends. Like Chris says,
there's no good reason for it, it just never came up.

-Larry Jones

See if we can sell Mom and Dad into slavery for a star cruiser. -- Calvin
 

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
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top