Re: opaque style question
From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 04/18/04
- Next message: Old Wolf: "Re: String Reverse Question"
- Previous message: Chris Torek: "Re: Linux Serial Programming"
- In reply to: Joe Wright: "Re: opaque style question"
- Next in thread: Dan Pop: "Re: opaque style question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 17 Apr 2004 22:12:52 -0400 (EDT)
On Sat, 17 Apr 2004, Joe Wright wrote:
>
> We may be going sideways here. I was responding to Dan's conjecture
> on whether FILE could/should be incomplete so as to be opaque. While
> you can declare a pointer to incomlete struct type, it would be
> problematic to assign meaningful values to such pointers.
No, it wouldn't. Look, what do you do with C's objects of type
'FILE *' at the moment? You can:
- Assign predefined values to them: fp = stdin;
- Assign new values to them: fp = fopen(...);
- Pass them to functions: fclose(fp);
- Pass their addresses to functions: my_open(&fp);
- Compare them for equality: if (fp == stdin) ...
- Compare them to predefined values: if (fp == NULL) ...
What other meaningful operations on file descriptors can you think
of?* Note that all of the above operations could be done whether
FILE were an opaque type or not. As it happens, FILE is *not* an
opaque type, but I agree with Dan Pop here --- there's no practical
reason for the Standard to say it mustn't be. It looks like just
one of C's "quirks."
-Arthur
[*] - I know the phrase "file descriptor" usually means something
else on Unixoid systems, but if I said "file-describer," I'd get
responses correcting my English. ;-) Standard C, as far as I know,
doesn't use the term "file descriptor" to mean either an integer
*or* a [pointer to a] FILE object.
- Next message: Old Wolf: "Re: String Reverse Question"
- Previous message: Chris Torek: "Re: Linux Serial Programming"
- In reply to: Joe Wright: "Re: opaque style question"
- Next in thread: Dan Pop: "Re: opaque style question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|