- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I have a fortran dll 'X' which is called both by a C++ dll and other fortran dlls.
The fortran dlls interface with each other easily.
If I try to have the C dll call X, I get the 'unresolved external _X@24' error. I'm trying to call from C:
X(int, double, double, double*)
I can force X to pass values in this format (int, double, and double by VALUE; double* by REFERENCE), but then the other fortran dlls cannot access X, I get the 'unresolved external __imp_X@'
How are all the values passed if I do not manipulate the VALUE/REFERENCE compiler options?
Is there a way I can define the 'X' function in C so that it will call X correctly without manipulating the compiler options in X?
BTW, my work around for this was to create anintermediate fortran dll wich I've set the VALUE/REFERENCE compiler options, then called X from there. I would like to get rid of the intermediate dll.
Thanks
Chris
The fortran dlls interface with each other easily.
If I try to have the C dll call X, I get the 'unresolved external _X@24' error. I'm trying to call from C:
X(int, double, double, double*)
I can force X to pass values in this format (int, double, and double by VALUE; double* by REFERENCE), but then the other fortran dlls cannot access X, I get the 'unresolved external __imp_X@'
How are all the values passed if I do not manipulate the VALUE/REFERENCE compiler options?
Is there a way I can define the 'X' function in C so that it will call X correctly without manipulating the compiler options in X?
BTW, my work around for this was to create anintermediate fortran dll wich I've set the VALUE/REFERENCE compiler options, then called X from there. I would like to get rid of the intermediate dll.
Thanks
Chris
Link kopiert
6 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
It would appear that your C code has declared X as __stdcall, thus the @24. Intel Fortran, by default, doesn't use STDCALL. If you show us the entire declaration of X in the C code we can suggest how to change it. This has nothing to do with value/reference. However, your declaration of X does have the first two arguments passed by value. If you changed all of the arguments to *int or *double, and passed addresses (&arg) rather than just the arg value, then it would work without changes in the Fortran. There is no way to avoid changing one or the other.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I have used STDCALL do define the function in C like this:
extern "C" void _stdcall STMPROP(int * runoption, double * pressure, double * temperature, double * RET);
I am also passing addresses with &
Is there a way to define it in C to avoid making changes to the fortran dll?
extern "C" void _stdcall STMPROP(int * runoption, double * pressure, double * temperature, double * RET);
I am also passing addresses with &
Is there a way to define it in C to avoid making changes to the fortran dll?
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Take out the __stdcall for a start.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
That did the trick.
Thanks
Thanks
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
How would I define a string in the routine?
I was thinking link this:
extern "C" void STMPROP(char * string, int strlen);
Haven't tried this yet, just curious.
I was thinking link this:
extern "C" void STMPROP(char * string, int strlen);
Haven't tried this yet, just curious.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Rather than int, use size_t. Also, all the string lengths go at the end of the argument list, so if you had two arguments, a string and a real, it would look something like this:
extern "C" void SUB(char * string, float *r, size_t strlen);
This assumes you are not using the C interoperability features of Fortran.
extern "C" void SUB(char * string, float *r, size_t strlen);
This assumes you are not using the C interoperability features of Fortran.

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