- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code snippet seems to be working fine in debug and causing access violations in release:
[fortran]
!------------------------------------------
! c_string to character string conversion.
function f_string(cStr,fStr_size) result (fStr)
type(c_string) :: cStr
integer :: fStr_size
character(len=fStr_size) :: fStr
!call c_string_to_character_string(fStr,cStr)
end function f_string
[/fortran]
Perhaps it is illegal to have the return length specified by dummy arg?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
David, you have been very naughty. You used BIND(C) to call a STDCALL routine, papering over the error by including the @n name decoration in the external names in the BIND clause. This causes stack corruption.
In Intel Fortran, BIND(C) cannot be used to call STDCALL routines - only the default C convention is allowed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah! I was unaware this was the case. The code now works fine.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In general, any time you find yourself adding the @n suffix to an external name string to fix up a linking error, that should be a red flag that you're probably doing something wrong.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page