Ok, I know this is a common topic, but I didn't find any post that
solves my current problem. I'm using Microsoft Visual C++ 6.0 (SP5),
and Intel Fortran 7.1 Compiler for Windows.
I'm trying to pass a C character string to my Fortran code.
Here is the code (a very simple one):
********** C print.c listing **********
#include <stdio.h>
extern "C" {
void __stdcall PRINT_STRING(char *);
}
int main(void)
{
char *cstring = "Hello World!";
PRINT_STRING(cstring);
return 0;
}
********** Fortran print.f listing **********
subroutine PRINT_STRING(fstring)
CHARACTER*30 fstring
print *,'Fortran string: ',fstring
end
*********************************************
The output is wrong, and I got something like:
" Fortran string: $"
(the '$' may change for any other ascii character)
So, I've tried the hidden-length method, but the linker doesn't like
it:
"test.obj : error LNK2001: unresolved external symbol _PRINT_STRING@8
Debug/test.exe : fatal error LNK1120: 1 unresolved externals"
(I only declare the length parameter into the C listing as written in
some posts here).
If someone got an idea on how to pass those strings, or got a miracle
lib/function to convert those C strings (remember, I use Intel Fortran
Compiler and there is nothing into the documentation that may help
about it...).
I can't neither use CHARACTER*(*) since the Fortran compiler is
complaining about "Error 531 : The variable CSTRING cannot be a value
dummy argument use CHARACTER(*) instead." (even if I use CHARACTER(*)
as written...).
Hey, dudes, help me!
Thanx a lot
Thanks!