- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi everyone,
I have some Fortran 77 sources file that I'd like to compile as a DLL so I can call functions from an external GUI to interact with Fortran DLLs.
I compiled the DLL with the latest version of the Intel compiler, and apparently the DLL is generated correctly and called from the external GUI (in C#).
But I've noticed a behavioral issue with the DLL because it doesn't return the expected value of a variable. The problem isn't related to the source file, since compiling the .for file in Visual Studio returns the correct values.
I believe the problem is in the compiler settings or in the directives inserted in the .for file; can anyone help me resolve the issue?
Thanks,
Valerio
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Ok I report the extract of my two files .for and .cs:
file .for 77 (two subroutine)
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I've solved using /Qsave parameter during the compilation, this permits to allocate the local variables into the memory without pass they into the stack.
cheers!
V.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
>>I've solved using /Qsave parameter during the compilation
Do you intend to (later) call your DLL from a multi-threaded process?
If so, then the /Qsave may be problematic.
Jim
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi,
yes I'm using multi-thread but each subroutine with /Qsave is called from only one dedicated thread so local variables should not be at risk of being overwritten.
Valerio
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Why might I have hidden problems? The Fortran source is secure and tested, including local variables. Even uninitialized variables will be assigned a value, the important is that the value is not lost.. or not?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
ok that's correct.
Just for info I'm using CallingConvention "Cdecl" C declaration so the caller (my C# GUI) clear the stack; in the file .for77 use this directive -> !DEC$ ATTRIBUTES DLLEXPORT :: name_of _subroutine
It's correct use this or better STDCALL? I honestly don't know which one is better to use. I only understood that they must be declared in the same way to correctly manage stack cleaning.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
As far as I know,
with cdecl convention, arguments are pushed to the stack before calling the procedure who doesn't have to know the actual size of arguments to return correctly. That allows variable number of arguments.
with stdcall convention,, it's the opposite so the called procedure use the declared size of arguments to get the return address from the stack. It's why the arguments size is added to the procedure name to avoid mismatches. Optional arguments must be declared and pushed as null pointer if absent to preserve the argument size.
cdecl guaranties that the procedure will return correctly even if arguments number or size is incorrect may be silently.
stdcall will crash if arguments number or size is incorrect.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Okk thk for your advice..I'll use Cdecl convention..;-)

- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite