a bit more on getopt

John Quarterman jsq at ut-sally.UUCP
Sat Jul 20 08:53:13 AEST 1985


bit more on getopt
Date: 19 Jul 85 11:32:03 EDT (Fri)

>  > Actually this is important in some applications which do not already use
>  > stdio and do not wish to load in the 10k or so overhead that using stdio
>  > incurs. AT&T's code does not use stdio in getopt(3).
> 
>  Not true.  The size difference between:
> 
>  	main() { puts("foo"); }
>  and
>  	main() { write(0,"foo",3); }
> 
>  is exactly zero.

Your second one-liner is still using stdio.  The difference between
       main() { puts("foo"); }
and
       main() { write(1, "foo", 3); }   exit(n) { _exit(n); }
on the other hand, is substantial, at least on my 4.2 VAX system (and, in my
experience, on other UNIX systems as well):

text	data	bss	dec	hex
2048	1024	15988	19060	4a74	stdio
1024	1024	0	 2048	 800	nostdio

1024       0    25988   17012           difference

The point about not using stdio in a library routine if it's not necessary
still stands.

	Dan Franklin



More information about the Mod.std.unix mailing list