- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hi,
I noticed that when I'm calling a C++ function from my Fortran code, the parameters lose their values.
The C++ function is declared as follows:
extern "C" void __cdecl
GerkCallback(double &inCurrentTime
double *fortranStateProbabilities,
double *fortranStateProbabilitiesDelta )
{
...
}
The Fortran code uses the function like this (I combined all the relevant code together):
REAL*8 T [REFERENCE]
EXTERNAL F
A = T
CALL F(A, YG, YGP)
As I debug this code, I see that A equals 0 before calling F, but when I get to the C++ function, the corresponding parameter inCurrentTime takes some random value. The other params are mangled as well. Both C++ and Fortran code are compiled with the _cdecl calling convention. Environment: VC++ .Net, Intel Fortran 7.1.
Pavel
I noticed that when I'm calling a C++ function from my Fortran code, the parameters lose their values.
The C++ function is declared as follows:
extern "C" void __cdecl
GerkCallback(double &inCurrentTime
double *fortranStateProbabilities,
double *fortranStateProbabilitiesDelta )
{
...
}
The Fortran code uses the function like this (I combined all the relevant code together):
REAL*8 T [REFERENCE]
EXTERNAL F
A = T
CALL F(A, YG, YGP)
As I debug this code, I see that A equals 0 before calling F, but when I get to the C++ function, the corresponding parameter inCurrentTime takes some random value. The other params are mangled as well. Both C++ and Fortran code are compiled with the _cdecl calling convention. Environment: VC++ .Net, Intel Fortran 7.1.
Pavel
- Marcas:
- Intel® Fortran Compiler
Link copiado
2 Respostas
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hmmm... too little data to bring a definitive conclusion. For the start, are A, YG, and YGP double precision variables? (I assume they are -- even if they aren't, symptoms would be different).
Try watching LOC(A), LOC(YG) and LOC(YGP) on Fortran side, and addresses of Callback's dummy arguments on C++ side. Are they the same?
Jugoslav
Try watching LOC(A), LOC(YG) and LOC(YGP) on Fortran side, and addresses of Callback's dummy arguments on C++ side. Are they the same?
Jugoslav
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I found the answer:
The variable A was typed implicitly, and apparently its type was not "REAL*8" (which is the same as double, which was expected by the C++ code). When I explicitly specified the type of A as REAL*8, the problem went away.
The variable A was typed implicitly, and apparently its type was not "REAL*8" (which is the same as double, which was expected by the C++ code). When I explicitly specified the type of A as REAL*8, the problem went away.
Responder
Opções do tópico
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora