Prof A Olowofoyeku wrote:
Hi
I have run into some problems with the translation of libplot.
<nip>
or something else?
The issue here seems to be the precise equivalent of the C "FILE" struct. I believe that the library wants to write to these "FILE *" stuff.
C "FILE" is an opaque pointer. Opaque means that all operations on it should go trough C library. It is completly different than Pascal file. AFAICS GPC has no support for C "FILE". In practice you can write:
type CFile = pointer;
You may use some tricks to ensure that all operations on CFile go trough library (like wrapping it iside a record or declaring it restricted). To really use it you need declarations for libc functions. Minimally:
function fopen(name : CString; mode CString): CFile; external name 'fopen'; function fclose(f : CFile) : CInteger; external name 'fclose';
and then: var f : CFile;
begin f := fopen('my_file.bin', 'rb'); if f = nil then begin writeln('Unable to open: ', 'my_file.bin'); Halt end; { Use f }
if fclose(f) <> 0 then writeln('Unable to close f');