Anybody know where to find old header files for C Programming on DOS?

I recently got the dumb idea of trying to make a 'benchmark' program for old IBM-PCs. I coded a simple (in terms of structure) C program that calculates the digits of PI (based off the Python code for Chudnovsky's algorithm on Wikipedia). As expected, it works perfectly fine in a modern C compiler for Windows, and it should (in theory) work the same on an old DOS compiler, as it's using very simple C functions (the most complex parts being sqrt and pow, both of which are called from the math.h header file).

I thought I could just inject it into a floppy, and compile it using an old C compiler like Microsoft C Compiler 1.0 off of WinWorld. While I managed to figure out how to get the compiler to work, the disks don't have the math.h or time.h header files, which are necessary for my code to work.

I tried copying the header files from a Turbo C diskette, but those don't seem to work with the old compiler, as math.h threw a bunch of errors when trying to compile. I'm not sure whether a Turbo C-compiled EXE will run on old (pre-DOS 3.0) versions of DOS either.

I'm probably gonna move on to making it work on DOS 3+ only (since nobody uses DOS 1 or 2), but it would still be neat if I could make a version for DOS 1 and 2 as well.

Comments

  • edited August 3
    I've never seen a C compiler that old :blush:
    I'm guessing it's before any C standards.
    Copying the headers wont work.

    I think you have three options.
    (1) search for a good mathematical explanation of the math and recreate the functions yourself, ie wiki etc.

    (2) search for trigonometric replacement code online, maybe on github.com.

    Also because the old DOS machines didn't have a float processor or even a math co processor, you should look at converting floats into fixed point math.
    Here is one that I know of (it's for the PlayStation but it should work on DOS).
    http://www.netyaroze-europe.com/~nslaven/triginfo.htm (360 degrees = 4096 fixed point math)

    (3) Or the easiest is just use an ANSI C compiler with math.h :blush:
    Watcom,DJGPP etc
  • I've never seen a C compiler that old :blush:
    I'm guessing it's before any C standards.
    Copying the headers wont work.


    Yeah, I found some other header files and tried, but math.h still doesn't work. Seems like the compiler doesn't understand the rest of my code either, as it throws errors for 'missing parenthesis'. The code does compile perfectly on Windows using GCC, so it's likely the Microsoft C Compiler has some weird quirks to it.

    Also because the old DOS machines didn't have a float processor or even a math co processor, you should look at converting floats into fixed point math.


    The system I'm emulating has a 8087 Math Co-Processor, so I think I'm good on that end.

    I think I'll either rewrite my code to work on the old compiler, or simply grab one of the ANSI C compilers you mentioned and hope they can compile for older DOS.
Sign In or Register to comment.