Hello,
while working with schemata in gpc I encountered a problem:
In the following program it seems the "array of vektor" a^ is created with the correct size but the components of the array do not know about their own size. I do not know if this is the expected behaviour. May be the compiler should either not allow this construct or otherwise initialize the array.
*********************************************************************************
TYPE vektor(n: Integer)=array[0..n-1]of double;
vektorarray(n: Integer)=array[1..100]of vektor(n); VAR a: ^vektorarray; BEGIN new(a, 3);
WriteLn(a^.n); { gives 3 } WriteLn(a^[10].n); { gives 0, should it be 3 ? } WriteLn(Sizeof(a^) ); {Writeln(Sizeof(a^[10]) );} {would result in compiler error " `SizeOf' applied to an undiscriminated schema " } END.
********************************************************************************** The output is:
3 0 2804
I am using gpc version 19991030, based on 2.95.2 19991024 (release)
Sven
Hi
On Wed, 21 Feb 2001, Sven Sahle wrote:
while working with schemata in gpc I encountered a problem:
In the following program it seems the "array of vektor" a^ is created with the correct size but the components of the array do not know about their own size. I do not know if this is the expected behaviour. May be the compiler should either not allow this construct or otherwise initialize the array.
TYPE vektor(n: Integer)=array[0..n-1]of double;
vektorarray(n: Integer)=array[1..100]of vektor(n);
VAR a: ^vektorarray;
BEGIN new(a, 3);
WriteLn(a^.n); { gives 3 } WriteLn(a^[10].n); { gives 0, should it be 3 ? }
WriteLn(Sizeof(a^) ); {Writeln(Sizeof(a^[10]) );} {would result in compiler error " `SizeOf' applied to an undiscriminated schema " } END.
The output is:
3 0 2804
I am using gpc version 19991030, based on 2.95.2 19991024 (release)
Uncommenting that last writeln gives
3 0 2804 28
using gpc version 20010211
Hopes this helps a little Russ
Hi,
I want to know if somewerre, ther is a description of how to write interrup procedures (like the interrupt in BP).
Like an interrupt is call by an 16 bits adress, I ask me how it is possible.
Thanks.
Opie.
Opie Pecheux a écrit :
Hi,
I want to know if somewerre, ther is a description of how to write interrup procedures (like the interrupt in BP).
Like an interrupt is call by an 16 bits adress, I ask me how it is possible.
djgpp is a rather clever system which switches back and forth between 16 bit real mode and 32 bits protected mode do enable that. elementary functions in C are given in the djgpp libc (see libc.info) some interface to pascal in contained in dos.pas (see this file in the units directory). Do not forget the switch -D__BP_UNPORTABLE_ROUTINES__ to enable these functions.
Salut
Maurice
Maurice Lombardi wrote:
Opie Pecheux a écrit :
Hi,
I want to know if somewerre, ther is a description of how to write interrup procedures (like the interrupt in BP).
Like an interrupt is call by an 16 bits adress, I ask me how it is possible.
djgpp is a rather clever system which switches back and forth between 16 bit real mode and 32 bits protected mode do enable that. elementary functions in C are given in the djgpp libc (see libc.info) some interface to pascal in contained in dos.pas (see this file in the units directory). Do not forget the switch -D__BP_UNPORTABLE_ROUTINES__ to enable these functions.
...and if your needs are not trivial, do not forget to check the DJGPP FAQ (http://www.delorie.com/djgpp/v2faq/). It has some things to say on interrutps etc. (in the chapter `Low-level' and maybe elsewhere)...
Frank
Sven Sahle wrote:
Hello,
while working with schemata in gpc I encountered a problem:
In the following program it seems the "array of vektor" a^ is created with the correct size but the components of the array do not know about their own size. I do not know if this is the expected behaviour. May be the compiler should either not allow this construct or otherwise initialize the array.
TYPE vektor(n: Integer)=array[0..n-1]of double;
vektorarray(n: Integer)=array[1..100]of vektor(n);
VAR a: ^vektorarray;
BEGIN new(a, 3);
WriteLn(a^.n); { gives 3 } WriteLn(a^[10].n); { gives 0, should it be 3 ? }
WriteLn(Sizeof(a^) ); {Writeln(Sizeof(a^[10]) );} {would result in compiler error " `SizeOf' applied to an undiscriminated schema " } END.
The output is:
3 0 2804
I am using gpc version 19991030, based on 2.95.2 19991024 (release)
Thanks for the bug report. The second problem has been fixed in more recnt versions like Russ said, the first one not yet. (sven19.pas)
Frank