Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Sep 1998 10:05:58 +0200 (MET DST)
From:      Jens Schweikhardt <schweikh@noc.dfn.de>
To:        grog@lemis.com (Greg Lehey)
Cc:        freebsd-chat@FreeBSD.ORG
Subject:   Re: Where can I find C
Message-ID:  <199809070805.KAA01593@obsidian.noc.dfn.de>
In-Reply-To: <19980907095317.L25397@freebie.lemis.com> from "Greg Lehey" at Sep 7, 98 09:53:17 am

next in thread | previous in thread | raw e-mail | index | archive | help
Greg et al,

# (redirected to -chat)
 
(now sent only to -chat and Greg)

# On Sunday,  6 September 1998 at 12:40:06 +0200, Jens Schweikhardt wrote:
# > # On Sat, 5 Sep 1998, Dusk Auriel Sykotik wrote:
# > # > On Fri, 4 Sep 1998, Scott Sewall wrote:
# > # > > main () {
# > # > >     printf("Hello World!\n");
# > # > > }
# > # > You can't use printf(), you didn't include stdio.h :)
# >
# > hello, world\n
# >
# > # Nah, it'll draw a warning, perhaps .... but this is perfectly legal C.
# >
# > What did you smoke tonight? :-)
# 
# K&R fiirst edition?  
 
Yes, yes, yes! I accept that "the very first" program can be interpreted
to mean "what K&R used in their 1st ed." It can also mean the canonical
first program, hello world, as it should be taught in any language.
Maybe I'm too biased from reading comp.lang.c where you would be tarred
and feathered to assert that calling variadic functions without a
prototype in scope "is perfectly legal C." As of C89 and C9X it's not.
We all know that, of course.

# > You call a variadic function with no prototype in scope
# > which leads to undefined behaviour as per ISO 9899:1990
# > This bombs as soon as the representation of int and char *
# > are different or if there are different passing mechanisms
# > for those types.
# 
# You're obviously very young, or you place too much trust in
# ``standards''.  The *very* first program in "The C programming
# language", by Brian W. Kernighan and Dennis M. Ritchie, first edition
# (1978), page 6, is:
# 
# main()
# {
#     printf("hello, world\n");
# }
 
I'm 31, and 11 years ago I taught myself C using K&R 1st ed.
You're right, I'm a standards fanatic. I find it a pity, that
FreeBSD isn't even C89 + Amendment 1 compliant. Lots of code
even violates C syntax gratuitously and for *no* reason at all [*]
(I suspect programmer ignorance -- in other words: not knowing
the Standard) making it impossible to compile those files with
compilers other than gcc.

I find C89 to be
one of the better standards out there; the ISO document is relatively
precise. Next come Standards from the IEEE, like e.g. POSIX. The
worst are the "vendor" standards, XPG4 or SVID. In any case, I rather
program to a standard, than to <random OS's interface>.

# > Note that only the spelling of hello, world\n as above is correct :-)
# 
# I didn't think it was standardized.

It's a de facto standard :-)

[*] absolutely unnecessary violations of C syntax in FreeBSD code:

 - labels without null statements at the end of a block
 - spurious semicolons after declarations at file scope
 - struct declarations without members
 - commas at the end of an enumeration list (C9X will allow that)
 - empty translation units

 The reason why this bullshit^Wbogus code is in the FreeBSD source is
 because gcc is not a Standard C compiler by default but has to be made
 so using some options (-ansi -pedantic and -lm). I'd rather have a
 standard C compiler where I have to request the *extensions* using
 options. But I'm fighting a lost battle here. :-(

 And yes, I have sent a PR about one of them (quota.h) a few days ago.
 I'll send another when I checked the whole source tree. Just in case
 anyone is wondering, no, I'm not eye-grepping the source, I have
 written a lexer and parser for ISO C and run that in a make world
 before doing the actual compilation with gcc.

Regards,

-- 
Jens Schweikhardt  http://www.shuttle.de/schweikh/
SIGSIG -- signature too long (core dumped)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809070805.KAA01593>