Click here to Skip to main content
15,922,007 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMixed language dll Pin
Kash26-Aug-05 6:20
Kash26-Aug-05 6:20 
I am trying to call a Fortran dll in my c++ code.

The fortran bit is as follows:

<br />
subroutine swap(x,y,z)<br />
real , intent(inout) :: x<br />
real , intent(inout) :: y<br />
real , intent(out) :: z<br />
real :: t<br />
!<br />
!DEC$ATTRIBUTES dllexport :: swap<br />
!DEC$ATTRIBUTES DEFAULT, DECORATE, ALIAS: 'swap' :: swap<br />
!<br />
t=x<br />
x=y<br />
y=t<br />
z=1.23<br />
end subroutine swap<br />
<\code><br />
<br />
The C++ calling code is:<br />
<br />
<code><br />
#include <iostream><br />
using namespace std;<br />
extern "C" __declspec(dllimport)void swap(double &x, double &y,double &z);<br />
int main() <br />
{<br />
	double x,y,z;<br />
	x	= 10;<br />
	y	= 999;<br />
	swap(x,y,z);<br />
	cout<<x<<"\t"<<y<<"\t"<<z<<endl;<br />
 return="" 0;<br />
}<br />
<\code=""><br />
<br />
There are some problems however. x and y are not swapped but they do display their original values on the console. And z has not been assigned a value. I think it's a problem with the C++ bit but I could be wrong. The good thing is that it compiles and executes.<br />
I will eventually try and do this in C# but one step at a time ;)<br />
<br />
Kash

AnswerRe: Mixed language dll Pin
David Crow26-Aug-05 6:50
David Crow26-Aug-05 6:50 
GeneralRe: Mixed language dll Pin
Tim Smith26-Aug-05 11:14
Tim Smith26-Aug-05 11:14 
QuestionCMenu selected Pin
picazo26-Aug-05 6:08
picazo26-Aug-05 6:08 
AnswerRe: CMenu selected Pin
Roger Allen26-Aug-05 6:11
Roger Allen26-Aug-05 6:11 
GeneralRe: CMenu selected Pin
picazo26-Aug-05 6:24
picazo26-Aug-05 6:24 
GeneralRe: CMenu selected Pin
Roger Allen26-Aug-05 6:51
Roger Allen26-Aug-05 6:51 
AnswerRe: CMenu selected Pin
David Crow26-Aug-05 6:11
David Crow26-Aug-05 6:11 
GeneralRe: CMenu selected Pin
picazo26-Aug-05 6:19
picazo26-Aug-05 6:19 
GeneralRe: CMenu selected Pin
David Crow26-Aug-05 6:40
David Crow26-Aug-05 6:40 
GeneralRe: CMenu selected Pin
picazo26-Aug-05 6:53
picazo26-Aug-05 6:53 
GeneralRe: CMenu selected Pin
David Crow26-Aug-05 7:01
David Crow26-Aug-05 7:01 
GeneralRe: CMenu selected Pin
Maximilien26-Aug-05 9:26
Maximilien26-Aug-05 9:26 
QuestionWS_CLIPCHILDREN causing MORE flicker?! Pin
Intangir26-Aug-05 6:07
Intangir26-Aug-05 6:07 
AnswerRe: WS_CLIPCHILDREN causing MORE flicker?! Pin
CWinThread27-Aug-05 2:25
CWinThread27-Aug-05 2:25 
QuestionSystem menu not refreshed Pin
Priyank Bolia26-Aug-05 5:01
Priyank Bolia26-Aug-05 5:01 
QuestionAdding words to a mouse over Pin
LCI26-Aug-05 4:58
LCI26-Aug-05 4:58 
AnswerRe: Adding words to a mouse over Pin
BlackDice26-Aug-05 5:28
BlackDice26-Aug-05 5:28 
GeneralRe: Adding words to a mouse over Pin
Laser126-Aug-05 11:53
Laser126-Aug-05 11:53 
QuestionChanging text color in a record list. MFC Pin
LCI26-Aug-05 4:54
LCI26-Aug-05 4:54 
QuestionWMP Plugin Activation Pin
Lafraia26-Aug-05 4:39
Lafraia26-Aug-05 4:39 
QuestionNaming convention Pin
Eytukan26-Aug-05 4:37
Eytukan26-Aug-05 4:37 
GeneralRe: Naming convention Pin
sunit526-Aug-05 4:43
sunit526-Aug-05 4:43 
GeneralRe: Naming convention Pin
Eytukan26-Aug-05 4:53
Eytukan26-Aug-05 4:53 
AnswerRe: Naming convention Pin
David Crow26-Aug-05 4:55
David Crow26-Aug-05 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.