BUG: Passing LOC() Intrinsic Result to C Function FailsLast reviewed: March 8, 1996Article ID: Q148203 |
The information in this article applies to:
- Microsoft Fortran PowerStation for Windows 95 and Windows NT, version 4.0
SYMPTOMSUsing a variable character substring as an argument to the LOC() intrinsic function and passing the result to a C function causes the variable character substring to become corrupted.
RESOLUTION
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Sample Code to Illustrate Problem and WorkaroundsC Fortran Main Source Code C Compile options needed: none
INTERFACE SUBROUTINE MYFUNC(I) INTEGER I !MS$ATTRIBUTES VALUE :: I !MS$ATTRIBUTES C,ALIAS:'_myfunc' :: myfunc END SUBROUTINE MYFUNC END INTERFACE CHARACTER STR*3, TEMP*4 INTEGER L STR = 'ABC' L = 3C this fails CALL MYFUNC(LOC(STR(1:L)//CHAR(0)))C these work CALL MYFUNC(LOC(STR//CHAR(0))) CALL MYFUNC(LOC(STR(1:3)//CHAR(0))) TEMP=STR(1:L)//CHAR(0) CALL MYFUNC(LOC(TEMP)) END
/* C Function Source Code: Compile options needed: /c */ #include <stdio.h> void myfunc(char *s){ long x; x = (long) s; printf("s: %x String: %s\n", x, s);}
Program Outputs: 12ffa8 String: - s: 12ffa4 String: ABC s: 12ffa0 String: ABC s: 41bac8 String: ABC
|
Additional reference words: 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |