[fpc-pascal]Two questions on initialisation of variables
Aitor Santamaria Merino
aitor.sm at wanadoo.es
Wed Mar 20 19:27:09 CET 2002
Hi,
Many of my programs start like this:
var
a, b,...: byte;
...
begin
a:= 5;
b:= 7;
...
So I was wondering if these sentences are translated into MOV sentences,
or for the contrary, compiler has optimisations that initialise the data
segment with the appropriate values, saving valuable CPU clocks.
If the answer is no, is there a way to do this, other than
CONST v: type = value;
that seems to me "inelegant" for Pascal?
And the second is for initialisation of PChars. The examples of
reference guide, pag 29, seem to suggest that I don't need to New()
pchars. Is that right? I suppose this is only at initialisaton time.
Suppose that for some reason I had to new a PChar, I suppose that New()
would only allocate 1 byte, so I'd have to use GetMem, am I right??
GetMem (p, maxsize+1);
Aitor
More information about the fpc-pascal
mailing list