Is it correct that an external variable can be declared in GPC as follows:
var eV: integer; external; asmname 'eV';
Is there a similar construct to declare external constants ('extern const' in C) ?
Regards,
Adriaan van Os
On Tue, Mar 18, 2003 at 01:37:31PM +0100, Adriaan van Os wrote:
Is it correct that an external variable can be declared in GPC as follows: var eV: integer; external; asmname 'eV';
Yes. In future releases, this statement might be var Foo: Integer; external name 'Bar';
Is there a similar construct to declare external constants ('extern const' in C) ?
Not as constants. In C: baz.c const int _c_bar = 42; In GNU Pascal (future release): baz.pas var Foo: const Integer; external name '_c_bar';
(As far as I remember)
A disadvantage of those constants is, that you cannot use them in a `case' statement.
Eike
Adriaan van Os wrote:
Is it correct that an external variable can be declared in GPC as follows:
var eV: integer; external; asmname 'eV';
Is there a similar construct to declare external constants ('extern const' in C) ?
Based on the grammar in parse.y, it looks like only Borland's static variable "constant" allows for external and asmname directives. But even that won't give you the semantics of C's extern const since it allows writes in addition to reads.
I think using your var declaration in conjunction with a protected export of "eV" will yield the correct result. Something like:
module test interface;
export C_external_constants = (protected eV);
var eV: integer; external; asmname 'eV';
end.
and then where you want to use the C extern const eV, just import the interface C_external_constants.
Gale Paeper gpaeper@empirenet.com
Adriaan van Os wrote:
Is it correct that an external variable can be declared in GPC as follows:
var eV: integer; external; asmname 'eV';
Yes -- but in the next release it will be
var eV: integer; external name 'eV';
Is there a similar construct to declare external constants ('extern const' in C) ?
In the next release:
var eV: integer; attribute (const); external name 'eV';
But these are typed constants -- neither untyped constants that can be used as `case' selectors nor BP's typed "constants" which are in fact variables.
Frank