A comment at the top of system.pas states:
{ Predefined constants, types, procedures, }
{ and functions (such as True, Integer, or }
{ Writeln) do not have actual declarations.}
{ Instead they are built into the compiler }
{ and are treated as if they were declared }
{ at the beginning of the System unit. }
Obviously, that's nowhere near a comprehensive list. Does anyone know where I could find the complete list?
EDIT: The responses I've got so far seem to be a bit confused as to what I'm looking for. I'm trying to find a list of the built-in constants, types, procedures and functions that the compiler recognizes but are not declared in any unit. Examples include High(), Writeln(), Assert(), string, etc.
For Procedures and Functions, go into the System Unit and look for the comment:
{ Procedures and functions that need compiler magic }
Below that is probably a fairly complete list. Just remove the leading underscore from each routine name.
For Keywords, the list at Delphi Basics:
are mostly "compiler magic", undeclared in any unit.
For Constants, a short list includes: MaxInt, MaxLongInt, Nil and Pi.
And as Ken said, you can find most of the Types near the top of the System unit.
I came here looking for the magic surrounding the leading underscore of functions and procedures in System.pas.
I found the utility tool DCU32INT (that parses *.dcu file and converts it into a close to Pascal form), also on github. It allows you to see both the buildin compiler defined functions that you are looking for, for example
function BlockRead
as well as the magic ones seen in the sources of system.pas, like
function _BlockRead
The functions which shows up from the .dcu file with a leading "@" sign (local symbol?) as:
function @BlockRead
this is offical list of magic functions. Good luck about types and constants!
It seemed a shame that no one has decided to make one so I will. I can't claim this is a comprehensive list. Its merely what I've been able to glean from either the documentation or by examining the source for missing identifiers. If you notice an omission feel free to edit the answer.
Many conditional symbols vary depending on the compiler's version and targeted platform but the following should be defined regardless of version or platform:
<nnn>
Here's one that appears to apply only to linux (at least in the version I'm using):
open
function with that signature defined anywhere in the code base. System.__open
has the same signature and points to the libc open
function but is not referenced outside the System unit so the compiler must be doing more "magic" to resolve open
to __open
.Some of the internally defined types can be found a little further down in System.pas (around line 90 in the version shipped with Delphi 2010 Update 4). You can find them easily with a search on "built-in types"; there's a list of {$EXTERNALSYM} declarations for C++Builder where things like String, AnsiString, etc. can be found.
As far as the procedures and functions, I don't know of any list anywhere. Allen Bauer or Barry Kelly might find this and be able to help, though.
The list of types and consts is also not official, but can be deduced from the System.pas sources if you have them. It also depends on the kind of compiler (support for Unicode, Kylix, .NET, etc.).
This is the relevant portion from the Delphi 2010 System.pas:
{$EXTERNALSYM CompilerVersion}
{$EXTERNALSYM Boolean 'bool' } {$OBJTYPENAME Boolean 'Bo'}
{$NODEFINE ShortInt 'ShortInt' } {$OBJTYPENAME ShortInt 'Bzc'} { signed char }
{-EXTERNALSYM ShortInt 'signed char' } {-OBJTYPENAME ShortInt 'Bzc'}
{$EXTERNALSYM SmallInt 'short' } {$OBJTYPENAME SmallInt 'Bs'}
{$EXTERNALSYM Integer 'int' } {$OBJTYPENAME Integer 'Bi'}
{$NODEFINE Byte 'Byte' } {$OBJTYPENAME Byte 'Buc'} { unsigned char }
{$NODEFINE Word 'Word' } {$OBJTYPENAME Word 'Bus'} { unsigned short }
{$EXTERNALSYM Cardinal 'unsigned' } {$OBJTYPENAME Cardinal 'Bui'}
{$EXTERNALSYM Int64 '__int64' } {$OBJTYPENAME Int64 'Bj'}
{$EXTERNALSYM UInt64 'unsigned __int64' } {$OBJTYPENAME UInt64 'Buj'}
{$EXTERNALSYM NativeInt 'int' } {$OBJTYPENAME NativeInt 'Bi'}
{$EXTERNALSYM NativeUInt 'unsigned' } {$OBJTYPENAME NativeUInt 'Bui'}
{$EXTERNALSYM Single 'float' } {$OBJTYPENAME Single 'Bf'}
{$EXTERNALSYM Double 'double' } {$OBJTYPENAME Double 'Bd'}
{$NODEFINE Extended 'Extended' } {$OBJTYPENAME Extended 'Bg'} { long double }
{$NODEFINE Currency 'Currency' 'CurrencyBase' } {$OBJTYPENAME Currency 'NCurrency'}
{$NODEFINE Comp 'Comp' 'CompBase' } {$OBJTYPENAME Comp 'NComp'}
{$EXTERNALSYM Real 'double' } {$OBJTYPENAME Real 'Bd'}
{$NODEFINE ShortString 'ShortString' 'ShortStringBase' } {$OBJTYPENAME ShortString 'N%SmallString$iuc$255%'}
{$NODEFINE OpenString 'OpenString' } {$OBJTYPENAME OpenString 'Bxpc'} { char * const }
{$NODEFINE File 'file' } {$OBJTYPENAME File 'Nfile'}
{$NODEFINE Text 'TextFile' } {$OBJTYPENAME Text 'NTextfile'}
{$NODEFINE ByteBool 'ByteBool' } {$OBJTYPENAME ByteBool 'Buc'} { unsigned char }
{$NODEFINE WordBool 'WordBool' } {$OBJTYPENAME WordBool 'Bus'} { unsigned short }
{$EXTERNALSYM LongBool 'BOOL' } {$OBJTYPENAME LongBool 'Bi'} { int } { from windef.h }
{$NODEFINE Real48 } { not supported in C++ }
{$EXTERNALSYM Pointer 'void *' }
{$NODEFINE PWideChar 'WideChar *'}
{$EXTERNALSYM PAnsiChar 'char *' }
{$NODEFINE Variant } { defined in sysvari.h }
{$NODEFINE OleVariant } { defined in sysvari.h }
{$NODEFINE LongInt } { alias of Integer }
{$NODEFINE LongWord } { alias of Cardinal }
{$NODEFINE TextFile } { alias of Text }
{$IFDEF UNICODE}
{$EXTERNALSYM AnsiChar 'char' } {$OBJTYPENAME AnsiChar 'Bc'}
{$IFDEF LINUX}
{$NODEFINE Char 'WideChar' } {$OBJTYPENAME Char 'Bus'} { unsigned short }
{-OBJTYPENAME Char 'BCs'} { char16_t }
{$ELSE}
{$NODEFINE Char 'WideChar' } {$OBJTYPENAME Char 'Bb'} { wchar_t }
{-OBJTYPENAME Char 'BCs'} { char16_t }
{$ENDIF}
{$NODEFINE string 'UnicodeString' } {$OBJTYPENAME string 'NUnicodeString'} { defined in vcl/ustring.h }
{-NODEFINE string 'String' } {$OBJTYPENAME string 'NUnicodeString'} { defined in vcl/ustring.h }
{$NODEFINE AnsiString } { defined in vcl/dstring.h }
{$NODEFINE WideString } { defined in vcl/wstring.h }
{$NODEFINE PChar } { alias of PWideChar }
{$NODEFINE WideChar } { alias of Char }
{$NODEFINE UnicodeString} { alias of string }
{$ELSE}
{$EXTERNALSYM Char 'char' } {$OBJTYPENAME Char 'Bc'}
{$IFDEF LINUX}
{$NODEFINE WideChar 'WideChar' } {$OBJTYPENAME WideChar 'Bus'} { unsigned short }
{-OBJTYPENAME WideChar 'BCs'} { char16_t }
{$ELSE}
{$NODEFINE WideChar 'WideChar' } {$OBJTYPENAME WideChar 'Bb'} { wchar_t }
{-OBJTYPENAME WideChar 'BCs'} { char16_t }
{$ENDIF}
{$NODEFINE string 'AnsiString' } { defined in vcl/dstring.h }
{-NODEFINE string 'String' } { defined in vcl/dstring.h }
{$NODEFINE WideString } { defined in vcl/wstring.h }
{$NODEFINE UnicodeString} { defined in vcl/ustring.h }
{$NODEFINE PChar } { alias of PAnsiChar }
{$NODEFINE AnsiChar } { alias of Char }
{$NODEFINE AnsiString } { alias of string }
{$ENDIF}
--jeroen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With