Newsgroups: comp.sys.next Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usenet From: Garance_Drosehn@mts.rpi.edu Subject: C Programming questions Message-ID: Nntp-Posting-Host: gilead.its.rpi.edu Reply-To: gad@eclipse.its.rpi.edu Organization: Rensselaer Polytechnic Institute Date: 5 Apr 91 03:46:07 GMT Lines: 50 Time for a few programming questions! I'm trying to port some C code to my friendly NeXTStation (400meg drive). I'm not much of a C or Unix wizard, so these questions might have obvious answers... 1) Is there some manual or set of manuals for programming the Next, or should I just look thru all the digital-library documents? 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) 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. The program loads fine but dies when I try to run it (with "memory access exception in NXZoneCalloc", presumably something in the environment isn't setup right). I then took (what I consider) the sleazy way out and used: cc -o my.app ${OBJECTS} which works fine. What parameters is cc sending on to ld? I have CFLAGS set to "-ansi -pendantic -g -Wimplicit", if that's of any interest. It's a quirk of mine that I feel silly using the compiler when I'm not actually compiling anything at that step. 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. Ie, a statement of: PLen += fprintf(fp, "%d", Num); will always add zero to PLen. On the other platforms that I've tried these routines on so far, fprintf returns the number of bytes it just printed. Is there something I'm missing here. I can get around this by using the %n conversion character, eg: fprintf(fp, "%d%n", Num, &Temp_Int); PLen += Temp_Int; but that makes it two statements instead of one, and looks kinda stupid anyway. Is there some way I could make fprintf work the way I'm expecting it to? Well, that's all the questions I remember at the moment. Send any and all suggestions to Garance_Drosehn@mts.rpi.edu (or gad@eclipse.its.rpi.edu) and I'd appreciate it. I'm not sure if comp.sys.next itself is a good place for long threads on programming suggestions... - - - Garance_Drosehn@mts.rpi.edu or gad@eclipse.its.rpi.edu (NeXT mail)