Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!bionet!agate!ziploc!eps
From: eps@toaster.SFSU.EDU (Eric P. Scott)
Newsgroups: comp.sys.next
Subject: Re: C Programming questions
Message-ID: <1466@toaster.SFSU.EDU>
Date: 5 Apr 91 04:32:31 GMT
References:
Reply-To: eps@cs.SFSU.EDU (Eric P. Scott)
Organization: San Francisco State University
Lines: 66
In article gad@eclipse.its.rpi.edu writes:
>1) Is there some manual or set of manuals for programming the Next, or should
> I just look thru all the digital-library documents?
Except for some of the hardcopy material shipped with every
system, all of the documentation is either available online as
part of the "Extended" (i.e. non-Crippled) release which you
have, or via anonymous FTP from various archive sites. The NeXT
documents basically cover the differences/extensions from 4.3
BSD. If you're using the NeXT as a "plain UNIX box" there are
plenty of references on BSD UNIX for all levels of expertise.
Find something you like.
>2) What I'm working on includes a library of subroutines. I can compile them
> OK, but what commands do I need to turn them into a subroutine library? (ie,
> a "libXXX.a" file)
ar
ranlib
>3) I tried to come up with the magic parameters to the "ld" command to load
> all my C object files into a runnable application. I tried
> ld -o my.app ${OBJECTS} -lsys_s -crt0.o
> but that was just guesswork and not suprisingly it didn't work very well.
Not surprisingly.
> I then took (what I consider) the sleazy way out and used:
> cc -o my.app ${OBJECTS}
> which works fine.
Right.
> It's
> a quirk of mine that I feel silly using the compiler when I'm not actually
> compiling anything at that step.
Too bad. That's what's portable. ld is subtly different on just
about every UNIX variant. Get out of the habit of using it directly.
>4) Once I got past the loader, the program basically works. One odd thing
> (compared to what I've seen on other platforms) is that the fprintf
> subroutine seems to always return a value of zero.
Different UNIX implementations disagree here. This is just
something you'll have to live with. You're the first person
I've seen who actually cared--usually the question comes up
with respect to sprintf.
> Is there some way I could make fprintf work the way I'm expecting
> it to?
Not really.
I primarily write two kinds of code:
1) "Don't kid yourself; this will never, ever run on
anything but a NeXT."
2) Intended to run on as many different UNIX dialects as
possible.
If (2) is reasonable, (2) is invariably the most useful,
even if it means lots of #ifdefs. I don't write a lot of (1).
I use cc -bsd heavily.
-=EPS=-