Difference between Turbo C++ and Borland C++ compiler

4.7k views Asked by At

I compiled two pieces of code using the Turbo C++ 3.0 and Borland C++ 5.02 compilers and came across some odd things. My two pieces of code are like these:

First piece of code

void main()
{
}

Second piece of code

#include <iostream.h>
#include <conio.h>

void main()
{
}

And I got these results from them:

  • Borland C++ (first piece of code): 51 KB
  • Borland C++ (second piece of code): 51 KB
  • Turbo C++ (first piece of code): 5.89 KB
  • Turbo C++ (first piece of code): 16.3 KB

I checked two Borland executable files with a hexadecimal viewer and realized they were exactly the same.

I examined the first piece of code from these compilers in IDA Pro and came across these graphs:

Turbo C++

Turbo C++

Borland C++

Borland C++

Now I have these questions I'd like you to answer:

  1. Why are Borland C++ compiled files the same when one of them clearly doesn’t have some include and another have?

  2. Why are Borland C++ compiled files that big? (nearly 10 times bigger) and what is compiled that have that much size?

  3. When I submit the first piece of code to this site, I can see the assembly code of the simple void main function and I realized that Borland C++ code is very much the same, but Turbo C++ assembly code is very very complicated and isn't the same. Why?

  4. Why does this simple code, that compiled with Turbo C++, create these many functions that you can see in it's graph?

1

There are 1 answers

0
Thomas Matthews On BEST ANSWER

I will do my best at answering these, but you may need to post your questions to the Borland forums for detailed answers. In any case, upgrade your compilers.

1-Why Borland C++ compiled files are the same when one of them clearly dosen't have some include and another have?

Your program has no functionality and is incorrect. (The main function returns an int, always.)

You can include all the header files you want. You don't use them, so there is no additional code generated.

Your program doesn't require any header files. The have the same functionality.

2-Why Boland C++ compiled files are that big? (nearly 10 times bigger) and what is compiled that have that much size?

There are many possibilities. You'll have to either look at the assembly code generated, machine code generated or post to the Borland forums.

This also depends on whether you compiled in Debug mode or in Release mode. It also depends on whether you compiled for static libraries or dynamic libraries.

Fundamentally, the Borland Compiler may be generating code that meets the standards required by later versions of Windows than Turbo C++ was required to support. Research the difference between ".com" and ".exe" formats.

3-When i submit First Code to this Site i can see the assembly code of simple void main function and i realized that Borland C++ code is very much the same but Turbo C++ assembly code is very very complicated and isn't the same, why?

See my answer to #2.

4-Why this simple Code that compiled with Turbo C++ create this much functions that you can see in it's graph?

Most likely because you are compiling in Debug mode; or because Turbo C++ is a simpler compiler, it doesn't optimize the libraries and code as much as Borland does. In Debug mode, there are symbolic information placed into the executable file.

By the way, the size of the executable may not be the size of the executable code placed in memory. The executable format allows for stuff other than executable code to be placed in the file, such as program symbols an line numbers.

Don't worry about program sizes anymore. Get the program working correctly, robustly and safely before optimizing for size.