how to use scandir()?
Jay Maynard
jmaynard at thesis1.hsch.utexas.edu
Wed Aug 29 07:12:57 AEST 1990
In article <KATSU.90Aug28105457 at sran14.sra.co.jp> katsu at sra.co.jp (WATANABE
Katsuhiro) thinks all the world's a VAX:
>>> n = scandir(".", namelist, NULL, NULL) is a reasonable call,
In article <13677 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) corrects him:
>No, it is not "reasonable". The only time you should pass uncast NULL
>arguments to a function is when there is a prototype for the function
>in scope, which is not possible in pre-ANSI C. In this particular case
>the last two arguments should be either (int(*)())NULL or (int(*)())0.
This bears repeating. Sloppy programmers get away with cruft like this on
benevolent architectures like the VAX, where everything is 32 bits and may
be freely interchanged; when this is tried on other machines, though, it blows
up because suddenly the wrong amount of stuff is added to or removed from the
stack.
If you're trying to write portable programs, please don't assume anything is
interchangeable with anything else!
--
Jay Maynard, EMT-P, K5ZC, PP-ASEL | Never ascribe to malice that which can
jmaynard at thesis1.hsch.utexas.edu | adequately be explained by stupidity.
"It's a hardware bug!" "It's a +---------------------------------------
software bug!" "It's two...two...two bugs in one!" - _Engineer's Rap_
More information about the Comp.unix.questions
mailing list