[LCP]creating files with open()
matthew at DaMOO.csun.edu
Tue Oct 9 14:54:35 UTC 2001
FILE is an opaque type whose internals ANSI does not define. On every libc
I've ever seen, it's a structure. Example: under linux with glibc
fgrep FILE /usr/include/stdio.h | fgrep typedef
/usr/include/stdio.h: typedef struct _IO_FILE FILE;
I've never heard of or seen a libc where typedef int FILE. Mike I think
you're getting confused between stdio's 'FILE *'s and the UNIX I/O layer,
with its 'small integer' file descriptors. Compare 'man 3 printf' and 'man
If you really have seen a libc with typedef int FILE, I'd like to know.
It's such a bad idea that that there might be humour value in the
On Mon, 8 Oct 2001, Mike & Penny Novack wrote:
> > Why do people keep saying "don't use int's, use FILEs"? As far as I
> > file descriptors (ints) are used internally by the OS, so a FILE is
> > a wrapper around a file descriptor.
> You are confusing two senses of "what is it". People are suggesting you
> use the type FILE because that IS the "type" defined to C. You are
> pointing out that "at the current time, in 99% of actual C
> implementations, the implementors chose to use "int" as the ACTUAL type
> assigned to FILE" (C has very few primative types). But the latter
> "fact" is not really part of C and thus isn't necessary always true nor
> if true now, true always.
> The best practice for writing truly portable (and permament) code is to
> include the standard "definitions" headers which resolve all the defined
> types via typedefs to the primative type used in THAT implementation. If
> this changes in some future implementation, why then the header file(s)
> supplied with that implemetation would have new values for the typedefs
> and everything recompiles correctly.
> Please note your program isn't going to run slower because you used
> typedefs (ie: the header file of them) than the "actual" types or
> constant values. That all gets resolved at compile time.
> This is the Linux C Programming List
> : http://lists.linux.org.au/listinfo/linuxcprogramming List
More information about the linuxCprogramming