- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to call a C++-function by a Fortran program. In C++ I only receive the first character whatever combinations of VALUE or REFERENCE attributes are applied. What can be the reason?
Fortran looks like this :
interface integer function fn(A) !DEC$ ATTRIBUTES DLLIMPORT, DECORATE, ALIAS:'fntestlib2' :: fn CHARACTER(5) A end function end interface ! Variables integer resres = fn('test')
C++ :
extern
"C"{
__declspec
(dllexport) int fntestlib2(char* s, unsigned int len_arg);}
}
__declspec
(dllexport) int fntestlib2(char* s, unsigned int len_arg){
return 42;}
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wasn't able to reproduce the failure you described using this program. Actually, I made two changes. In the Fortran program, I null-terminated the string, as:
res = fn('test'//char(0))
And, in the C++ program I output the string that was passed in, and it looked fine.
I assume there is a DLL involved here, based on the "dllimport/dllexport" directives; is there a chance your test is finding the wrong DLL?
- Lorri

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