Re: Write to file from DLL

halvor.lund@xxxxxxxxx wrote:
On 21 Jun, 11:31, gsal <salger...@xxxxxxxxx> wrote:
I personally don't use DLL, I just use static libraries; in any case,
I don't see this matter making the difference. Also, I have never
needed to use $pragma...what does that do you? If the library's
procedure that I want to use is a function, I simply declared it
in my program; if the library's procedure is a subroutine, I do

Using the Watcom IDE, it was the only way I was able to tell the
compiler which functions should be exported. Without "*$pragma aux
functionname export", it always complained that there were no exports.

Whenever that happens to me, it is because the size of INTEGER in
the library is different to the size of INTEGER in my program.

Thanks for your answer, but I'm afraid I've tried what you are
suggesting. I too thought of the possibility that the data types had
different sizes, but even when specifically specifying INTEGER*4
(corresponding to sizeof(int)==4) I had the same problem.

When sending integers from C to the fortran DLL function, it always
recieved 0.
When sending references to integers from C to the fortran DLL
function, it always recieved the same number, regardless of which
integer originally sent.

Between Fortran and C the convention is by value for C for an int by default but by reference for Fortran. You need to make both expect the same via pragma directive(s).

It's been long enough since I've used Watcom I don't recall the form and don't have it installed on this machine to look. IIRC there are examples in the Watcom doc's on making simple DLLs that should provide the roadmap. If that fails you may get more specific input in the OW forum.