[LCP]creating files with open()

Mike & Penny Novack stepbystepfarm at shaysnet.com
Tue Oct 9 09:55:04 UTC 2001


>
> Why do people keep saying "don't use int's, use FILEs"? As far as I
know,
> file descriptors (ints) are used internally by the OS, so a FILE is
actually
> 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.

Mike




More information about the linuxCprogramming mailing list