[comp.os.vms] VAX C typedef oddity

PJS@NAIF.JPL.NASA.GOV (Peter Scott) (07/27/88)

	typedef struct _iobuf*	FILE;

I can't find mention of this post-fixed usage of the asterisk.  Is this
equivalent to

	typedef struct *_iobuf	FILE;

?  What's happening here?

Peter Scott (pjs%grouch@jpl-mil.jpl.nasa.gov)

jkingdon@chinet.chi.il.us (James Kingdon) (07/28/88)

In article <880721084219.00000643081@naif.JPL.NASA.GOV> PJS@naif.JPL.NASA.GOV (Peter Scott) writes:
>
>	typedef struct _iobuf*	FILE;
>
>I can't find mention of this post-fixed usage of the asterisk.  

Try writing it
   typedef struct _iobuf *FILE;
which just means that FILE means pointer to struct _iobuf

Here as in most of C the spaces don't matter, and are only necessary to
separate typedef from struct and things like that.  (For some wonderful
abuse of this property, see the C Obstrufucated code contest results just
posted to comp.lang.c.)

tim@brspyr1.BRS.Com (Tim Northrup) (07/28/88)

From article by PJS@naif.JPL.NASA.GOV (Peter Scott):
| 
| 	typedef struct _iobuf*	FILE;
| 
| I can't find mention of this post-fixed usage of the asterisk.  Is this
| equivalent to
| 
| 	typedef struct *_iobuf	FILE;

No, I think it would be equivalent to

	typedef struct _iobuf *FILE;

FILE is being defined as "pointer to _iobuf structure", the spacing
on either side of the asterisk being ignored.

But this seems strange -- every other system defines FILE not as a pointer
type, but a structure type?  Very odd.  What is going on here?

-- 
Tim Northrup      		  +------------------------------------------+
+---------------------------------+         GEnie:  T.Northrup               |
UUCP: uunet!steinmetz!brspyr1!tim |   Air Warrior:  "Duke"                   |
ARPA: tim@brspyr1.BRS.Com	  +------------------------------------------+

scjones@sdrc.UUCP (Larry Jones) (07/30/88)

In article <4147@brspyr1.BRS.Com>, tim@brspyr1.BRS.Com (Tim Northrup) writes:
> 
> 	typedef struct _iobuf *FILE;
> 
> FILE is being defined as "pointer to _iobuf structure", the spacing
> on either side of the asterisk being ignored.
> 
> But this seems strange -- every other system defines FILE not as a pointer
> type, but a structure type?  Very odd.  What is going on here?

Unlike "every other system", VAX-11 C allows an unlimited number of files.
Instead of having a fixed-size array of _iobuf structures they malloc them
as needed, thus FILE becomes a pointer rather than a structure.

----
Larry Jones                         UUCP: ...!sdrc!scjones
SDRC                                AT&T: (513) 576-2070
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150
Nancy Reagan on superconductivity: "Just say mho."

LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (07/31/88)

	Sys$Library:  STDIO.H contains the line:

		typedef struct _iobuf*	FILE;

	I can't find mention of this post-fixed usage of the asterisk.  Is
	this equivalent to

		typedef struct *_iobuf	FILE;

	?  What's happening here?

Your eyes are playing tricks on you.  Try changing the spacing on the first
line:

		typedef struct _iobuf	*FILE;

Clearer now?
							-- Jerry

LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (08/01/88)

	...FILE is being defined as "pointer to _iobuf structure", the spacing
	on either side of the asterisk being ignored.

	But this seems strange -- every other system defines FILE not as a
	pointer type, but a structure type?  Very odd.  What is going on here?

FILE is an "opaque type"; programs really have no business trying to look
inside a FILE object, whatever it has been implemented as.  It happened to be
more convenient for the VAX C RTL to add a level of indirection; you'd have
to look through the internal details to figure out why.  What's the big deal?

							-- Jerry