Subject: Re: Beginner C Programming Questions
To: Jeff Flowers <jeffrey@jeffreyf.net>
From: Frederick Bruckman <fredb@immanent.net>
List: netbsd-help
Date: 04/19/2002 11:01:29
On Fri, 19 Apr 2002, Jeff Flowers wrote:

> I am starting to pursue C programming.  I will be using NetBSD 1.5.2 at home
> for this, so I will have to install the developers stuff; I usually do not.
> So, I have some questions:
>
> 1. I know that NetBSD uses the GNU compiler but what about make? Does GNU's
> make (gmake?) come with the system or does NetBSD use the BSD make combined
> with GNU's compiler? (I assume that the libraries included with NetBSD is
> not the GNU C library.)

Most ports now use the GNU compiler, linker, assembler, binutils and a
few other utilities, but not GNU make. There's a package for gmake, if
you need it. The source for the base installed GNU utilites is
collected under "src/gnu", if you want to see exactly what is there.
(I suggest you checkout the source, for examples of fine programming
style. ;-))

> 2. I have just become aware of a tool called Lint, which sounds useful. Is
> Lint included with the developer tools or is that a separate package? I have
> also become aware that there is more the one Lint-style program to choose
> from. Is there any consensus on what to use?

The full install includes a lint program, and prebuilt lint libraries
for all the libraries installed with the base system.

> 3. I have the K&R book (ANSI/2nd edition) and it shows an example of
> compiling a program with cc. According to the book, the compiler will create
> an executable named a.out. Is this still correct or will I end up with
> something different?
>
> (By the way, NetBSD went from a.out to ELF. Is this a coincidental name?)

Bingo. The default output is still "a.out", though, because to change
it would have broken a lot of configure scripts. (The change was
driven by the gcc people, to whom this would matter a lot.) For your
own programs you would usually use the '-o' flag to set the name of
the output file. By the way, BSD make doesn't even need a "Makefile"
for the simplest cases -- if you have a file "foo.c", `make foo' will
do the right thing!

Frederick