[vox-tech] writing free getopt, ran into a dilemma...
Micah Cowan
vox-tech@lists.lugod.org
01 Apr 2002 02:14:51 -0800
On Mon, 2002-04-01 at 00:56, msimons@moria.simons-clan.com wrote:
> I checked my copy of source which I got via "apt-get source glibc"
> with timestamps shown [way] below. Both my header and source files have
> references to the 'GNU Lesser General Public License':
>
> glibc-2.2.5/posix/getopt.c
> # The GNU C Library is free software; you can redistribute it and/or
> # modify it under the terms of the GNU Lesser General Public
> # License as published by the Free Software Foundation; either
> # version 2.1 of the License, or (at your option) any later version.
At the time that this topic came up previously, in which we decided the
license was debatable, I don't believe glibc's getopt.c nor getopt.h had
this text. I just examined my system, and it matches your text. So
that presents an easy enough solution :)
libiberty's getopt.c (from, say, gcc-3.0.3) still has the GPL text.
<snip>
> Okay so I've now stumbled on a copy of the ISO draft standard,
> dated about the middle of January 1999. Thanks for the link,
> I'll keep that in mind if I ever need the 'real thing'.
>
> I agree 100% const is not part of main in the standard.
>
> However, I found that
> int main(int argc, char **argv, char **envp);
> is listed as a 'common extension' it appears that the ISO rule is
> extensions which can not cause a valid ISO C program to break when
> compiled in that environment are allowed by the standard. (In
> my opinion since main with envp isn't defined by the standard the
> programs that use that form of main are not ISO C programs even through
> every other line may be ISO C ;)
Absolutely. In fact, this is how the language lawyers on comp.lang.c,
and the standard's developers in comp.std.c view this. The fact that
this is a common extension does not mean that it won't cause a valid ISO
C program to break. Because that version of main() doesn't match the
allowed forms by the standard, it requires a diagnostic message in
conforming implementations, and if the program compiles, the behavior is
undefined.
Note: since you're reading from the C9x draft... C99 adds extra verbage
allowing arbitrary "implementation-defined" versions of main();
basically, the impact is that a conformant compiler is now allowed to
accept those without a warning, and the behavior is no longer undefined
(its implementation-defined). However, there is only one C99-conforming
compiler in existance at the moment, and chances are very good you're
not using it (it's not gcc - gcc still seems to be depressingly distant
from a conformant C99 implementation).
<snip>
Micah