Thamm, Russell wrote:
[...] I would have thought that if I declared a 'C' array variable to be a pointer, and a function parameter to be a pointer, that when I pass the variable to the function, PASCAL should pass a pointer. However, this is not the case for 'C' array variables.
The problem lies in the C, not in the Pascal code:
int c1array[5] = {0x01010101,0x02020202,0x03030303,0x04040404,0x05050505};
This does declare an array, *not* a pointer. It's just that C implicitly adds a `&' when assigning an array value to a pointer variable or parameter.
Please try the following (not tested):
int carrayvalue[5] = {0x01010101,0x02020202,0x03030303,0x04040404,0x05050505}; int *carray = carrayvalue;
carray : __asmname__ 'carray' CCARRAY_PTR;
For this declaration the linker just passes a memory reference - to an array, not to a pointer. Pascal interprets the values found there as a pointer which is not what you want. Pascal does not know that this is in fact an array which must be `&'ed implicitly.
print_array(&carray); {this & seems wrong}
Indeed, and GPC should give you at least a warning.
On another matter, I downloaded the latest binary of GPC (gpc-19980830.i386-djgppv201.zip). Now, I keep getting a linker error about crt0.o. How do I overcome this?
Did you install gcc-2.8.1 for DJGPP in the first place? It's libraries are needed for GPC. Also, an old version of GPC or GCC can interfere with the new installation; better remove the old one.
Hope this helps,
Peter