Hi all,
I have come across a problem (bug? feature?) trying to pass a string schema
parameter to a procedure with a parameter defined as a __cstring__. Please
note that I am still using ver 2.0 so if this is fixed in the newer version,
let me know. Here is the problem:
This program works:
8<--------------------------------------------------
program works1;
(* GPC 2.0 *)
procedure foo(abar : __cstring__);
begin
(* dummy proc *)
end;
var
blab : string (200);
begin
blab := 'Test Me';
foo(blab);
end.
8<--------------------------------------------
However, the following program does not. I get the following error when
trying to compile:
dwork1.pas: In function 'program_Dwork1':
dwork1.pas:16:incompatible type for argument 1 of 'Foo'
8<---------------------------------------------
program dwork1;
(* GPC 2.0 *)
type
aCString = __cstring__;
procedure foo(abar : aCString);
begin
(* dummy proc *)
end;
var
blab : string (200);
begin
blab := 'Test Me';
foo(blab);
end.
8<------------------------------------------
Also, if I define a proc in a unit like:
procedure foofoo(acstr : __cstring__);
and call it from a different program like:
foofoo(SomeStrSchema);
I get the same error as above DWORK1.PAS program.
*******************************************************
Regarding the Pascal -vs- C calling, I like your suggestion, Peter. I would
much rather have the string variant be the default but provive the bare
ncurses calls just in case. However, the naming may need to be like: pfoo()
and cfoo(). The way I understand linking to a C rtn like:
function cfoo(SomeNum : integer) : integer; C;
requires that I link a C library that contains a function called `cfoo'. If
I could specify a different C fcn name to link to ( I think this was
discussed before) I could call the procedures almost anything!
Thanks much!!!
Ken L.