- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First of all thanks to everyone who helped me get this far. I finally got my test program to the point where it executes, but for some reason the address I'm passing from my C routine to the fortran subroutine is being treated as a value not an address.
Ive attached the 2 test files below
Any thoughts would be appreciated.
Thanks again
Scott
Ive attached the 2 test files below
Any thoughts would be appreciated.
Thanks again
Scott
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You forgot to add the INTERFACE block in the SUBROUTINE code.
An explicit interface is apparently a requirement for this to work. Try the following (after editing out the
blanks and the
s that the forum software is adding at random!!!! - PLEASE GET THIS FIXED!!!):
The above works for me using the Compaq VF compiler.
P.S. to Steve Lionel, when I change the double-underline
'__stdcall' in the EXTERNAL 'C' statement in the C++ code
to a single underline, there is no apparent change in
behaviour and no compiler objections. SO, what is the
point of the double as opposed to single underline?
An explicit interface is apparently a requirement for this to work. Try the following (after editing out the
blanks and the
s that the forum software is adding at random!!!! - PLEASE GET THIS FIXED!!!):
SUBROUTINE ENGAGEABILITY_INIT(int1) interface subroutine FORTRANTEST(int1) !DEC$ ATTRIBUTES C, ALIAS:'_ENGAGEABILITY_INIT@4' :: ENGAGEABILITY_INIT integer int1 end subroutine FORTRANTEST end interface ! Expose subroutine Fortran to users of this DLL !DEC$ ATTRIBUTES DLLEXPORT:: ENGAGEABILITY_INIT integer int1 int1 = int1 + 10 return END SUBROUTINE ENGAGEABILITY_INIT
The above works for me using the Compaq VF compiler.
P.S. to Steve Lionel, when I change the double-underline
'__stdcall' in the EXTERNAL 'C' statement in the C++ code
to a single underline, there is no apparent change in
behaviour and no compiler objections. SO, what is the
point of the double as opposed to single underline?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!DEC$ATTRIBUTES C changes the default argument-passing mechanism to by-value. If you want it to be by reference, specify REFERENCE attribute as well.
See "ATTRIBUTES" entry in Programmer's guide for detailed explanation, especially C, STDCALL, VALUE and REFERENCE attributes. Interactions between these are a bit complicated (the latter two can be specified for routine and/or for its arguments, with slightly different semantics), so read it carefully.
Jugoslav
See "ATTRIBUTES" entry in Programmer's guide for detailed explanation, especially C, STDCALL, VALUE and REFERENCE attributes. Interactions between these are a bit complicated (the latter two can be specified for routine and/or for its arguments, with slightly different semantics), so read it carefully.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feel frustrated by the Forum Tony? I sympathize with you. FYI, your post ended up in the wrong thread; you probably wanted to respond to matthewkmk.
Jugoslav
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The forum vendor has been informed of the problems here - I have no idea what triggered them, some change that was evidently made late last week... Sorry for the inconvenience, it annoys me as much as it does you.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"P.S. to Steve Lionel, when I change the double-underline
'__stdcall' in the EXTERNAL 'C' statement in the C++ code
to a single underline, there is no apparent change in
behaviour and no compiler objections. SO, what is the
point of the double as opposed to single underline?"
You're asking me a C++ question? :-)
As far as I understand, __stdcall, with two underscores, is the way you spell this in Visual C++. I think the two-underscores is a convention to avoid conflicts with user macros, but maybe a single underscore macro is also defined. Dunno.
Steve
'__stdcall' in the EXTERNAL 'C' statement in the C++ code
to a single underline, there is no apparent change in
behaviour and no compiler objections. SO, what is the
point of the double as opposed to single underline?"
You're asking me a C++ question? :-)
As far as I understand, __stdcall, with two underscores, is the way you spell this in Visual C++. I think the two-underscores is a convention to avoid conflicts with user macros, but maybe a single underscore macro is also defined. Dunno.
Steve

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