cazier@mbunix.mitre.org (Cazier) (08/09/90)
I just converted a FORTRAN program to its C equivalent using ANSI restrictions under a turbo C environment. I then moved the source code to a UNIX-PC using "cc" there to see if I had written a portable equivalent. The UNIX-PC complained of not finding "stdlib.h", a requirement by turboC. I imagine that turboC has put out a rather good implementation of its ANSI compiler, so is it the UNIX-PC compiler that's at fault or am I playing with a toy compiler on the DOS side of the house to fit BIOS requirements?
flaps@dgp.toronto.edu (Alan J Rosenthal) (08/11/90)
cazier@mbunix.mitre.org (Cazier) writes: >... [developed] using ANSI restrictions under a turbo C environment. >... UNIX-PC complained of not finding "stdlib.h" ... >... so is it the UNIX-PC compiler that's at fault or am I playing with a toy >compiler on the DOS side of the house to fit BIOS requirements? The ansi C committee invented enough things that it's unlikely that a program written with only ansi-c portability in mind will work on a non-ansi-c compiler. The unix-pc compiler is probably at fault only in that it is not ansi-compliant. Of course, your turbo C compiler is probably not entirely ansi-compliant unless it's a very recent version which came out after the standard was published in its final form. Very wide portability these days can probably be achieved only by referring to BOTH editions of Kernighan and Ritchie, and mostly the first. void, enum, and structure assignment are probably ok, but otherwise you should probably stick to the first edition, except where the second edition contradicts it (e.g. don't write into string constants). ajr
gwyn@smoke.BRL.MIL (Doug Gwyn) (08/11/90)
In article <116506@linus.mitre.org> cazier@mbunix.mitre.org (Cazier) writes: >The UNIX-PC complained of not finding "stdlib.h"... Assuming it was #include <stdlib.h>, and not #include "stdlib.h", you've found one non-conforming feature of the UNIX-PC "cc". I bet there are many others; the first ANSI-conformant C compiler bundled with AT&T UNIX was supposedly the one in SVR4.0.