- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm just trying to clarify whether or not it is possible to call a member function of a C++ Object from Fortran.
I'm assuming it's not possible but the way to get around it, would be to call a regular static C function which would then be used as a link between the desired Object's method and Fortran.
Thanking whoever can clarify this in advance,
Dawkins
I'm assuming it's not possible but the way to get around it, would be to call a regular static C function which would then be used as a link between the desired Object's method and Fortran.
Thanking whoever can clarify this in advance,
Dawkins
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As you probably know, C++ member functions have
Another issue could be calling conventions; AFAIK MSVC++ uses __fastcall as the default, where two arguments are passed through registers and the rest using stack. I don't know the details (and I'm not even sure about the above statement), but that cannot be emulated in VF. Thus, I think you'd be able to do it only if you declare the member functions __stdcall or __cdecl in VC++. (If it's another compiler, check the documentation about default calling convention). Note also that MSVC mangles names in a naughty way by default (e.g.
Jugoslav
this
as the first hidden parameter; thus, in theory, you could call them from Fortran provided you get a C pointer to the class object somehow, write a proper INTERFACE block and call the method, passing the pointer as the first argument. Another issue could be calling conventions; AFAIK MSVC++ uses __fastcall as the default, where two arguments are passed through registers and the rest using stack. I don't know the details (and I'm not even sure about the above statement), but that cannot be emulated in VF. Thus, I think you'd be able to do it only if you declare the member functions __stdcall or __cdecl in VC++. (If it's another compiler, check the documentation about default calling convention). Note also that MSVC mangles names in a naughty way by default (e.g.
?_Foo@YAXXUZ
), so your INTERFACE block must take that into account too. Jugoslav

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