Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 14778, Explanation of Internal Error

by Steve Trefethen Email: Anonymous

Information on internal error messages produced by the Delphi compiler.
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 2.0  to 6.0 18 downloads
Copyright: No significant restrictions

Size: 0 bytes
Updated on Fri, 18 May 2007 13:45:21 GMT
Originally uploaded on Mon, 05 Jun 2000 00:00:00 GMT
Compiling my Delphi application causes "Internal Error", what does this mean?

Compiler Messages Expert (for users of Delphi 6.0)

Before I get started, I've written a Delphi 6.0 expert that provides additional help on Delphi compiler messages which is available here Along with providing additional information on Internal Errors this expert provides help on over 33 different kinds of compiler messages. Please link to this page or others on this site and let people know that this expert is available.

Internal Errors

Occasionally when compiling an application in Delphi compilation will halt with an error message that reads "Internal Error: X1234" (this is just an example). While this error seemingly means very little to the end user there are steps one can take to try and resolve the problem. Let's start with an explanation of the error message. "Internal Error" indicates that the compiler has encountered a condition, other than a syntax error that it cannot successfully process. The information following "Internal Error" is usually one to three characters immediately followed by a number that indicates the file and line number inside the compiler itself where the error occurred. While this information isn't helpful to the enduser it can help us (Borland) track down the problem if/when it is reported.

What to do when you encounter an "Internal Error"

1. If the error occurs immediately after you have modified code in the editor go back to the spot where you made your changes and make a note of what was changed.
2. If you can undo or comment out the change and recompile your application successfully it is possible that the programming construct that you were using exposes a problem with the compiler so jump down to step 7. If not try, the next few steps to resolve your problem.
3. Delete all of the .DCU files associated with your project.
4. Close your project completely using File | Close All, then reopen your project, this will clear the unit cache maintained in the IDE. 5. Alternatively you can simply close the IDE and restart.
Another options is to try and recompile your application using the Project | Build option so that the compiler will regenerate all of your DCUs.
6. If the error is still present exit the IDE and try to compile your application using the command line version of the compiler (dcc32.exe) from a command prompt. This will remove the unit caching of the IDE from the picture and could help to resolve the problem.
7. If the problem still exists go back to the place where you last made modifications to your file and review the code.

Configuring the IDE to avoid Internal Errors

Create a single directory where all of your .DCP files (precompiled package files) are placed. For example create a directory called C:\DCP and under Tools | Enviroment Options select the Library tab and set DCP output directory to C:\DCP. This setting it will help ensure that the .DCP files the compiler generates are always up-to-date which is particularly useful when you move a package from one directory to another. Similarly I suggest creating a .DCU directory which can easily be done on a per-project basis using Project | Options | Directories/Conditionals | Unit output directory. The key here is that you always want to be using the most up-to-date versions of your .DCU and .DCP files otherwise you may encounter internal errors which are easily avoidable.

Identifying code that causes internal errors

Typically, most internal errors can be reproduced with only a few lines of code and frequently the code involves syntax or constructs that are rather unusual or unexpected. If this is the case you can try modifying the code to do the same thing in a different way. For example, if you are typecasting a value try declaring a variable of the cast type and do an assignment first.

Like this:

if Integer(b) = 100 then...

a: Integer;
a := b;
if a = 100 then...

Here is an example of unexpected code which can be corrected by the developer to resolve the error:
A : Integer;
{ Below the second cast of A to an In64 is unnecessary, removing it can avoid the Internal Error. }
if Int64(Int64(A))=0 then

Techniques for Resolving Internal Errors

Here are some ways to try and resolve internal errors:
- If the problem seems to be within a "" loop try using a "" loop instead or vice versa.
- If it uses a nested function or procedure try "unnesting" them.
- If it occurs on a typecast look for alternatives to typecasting.

When all else fails

Typically there are many different ways to write any single piece of code and use that to your advantage to try and resolve internal error by changing the code. While this may not be the best solution it may help you to continue work on your application. If this resolves the problem it does not mean that either "while" loops or "for" loops are broken but perhaps that the manner in which you've written your code was unexpected and therefore resulted in an error. If you've tried your code on the latest release of the compiler and it is still reproducible please create the smallest possible test case that will still reproduce it and submit it to Borland. If it is not reproducible on the latest version it is unlikely that we will go back and update the version you are using so be creative in looking for ways around the problem!

For more information, see

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04