[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
procedure/function header; asmname name;
or
variable declaration; asmname name;
The `asmname' directive declares the external name of a procedure, function or variable. The external name of the routine is given explicitly as a case-sensitive string constant. This is useful when interfacing with libraries written in other languages.
With this extension it is possible to access all external functions, for example the X11 interface functions, and not only those written in lowercase.
The idea to use `external' for this purpose (to avoid name space pollution) conflicts with another Borland extension not yet implemented: In Borland Pascal, the declaration
procedure Foo; external 'MyLib'; |
`asmname' can also be applied to units and module interfaces. In this case it denotes the prefix prepended to the external name of the initializer of the unit: While it is normally called `init_Modulename', it is called `init_asmname_Modulename' when `asmname' is given.
This is not of interest under normal circumstances since the initializers are called automatically. It can help avoiding conflicts when there are several units of the same name within one program. Again, this does not happen normally, but e.g., when a program uses a unit/module that has the same name as one of the units the RTS consists of: The RTS uses `asmname' for its units to avoid conflicts.
In the future, an `asmname' declaration applied to units, modules and programs (the latter is recognized syntactically already, but has no effect yet) will also affect the default external name of routines and variables which have no `asmname' declaration themselves. Again, this is mostly useful for libraries etc., and will not be necessary for normal units, modules and programs.
`asmname' is a GNU Pascal extension.
program AsmnameDemo; |
section 9.35 C, section 9.42 c_language, section 9.84 external, section 8.11.1 Importing Libraries from Other Languages.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |