- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include
extern "C"
{
void __stdcall FR1(int *,int *,char *);
}
void main()
{
int n=10,nSq;
char szCtest[20];
strcpy(szCtest,"teststring");
FR1(&n,&nSq,szCtest);
cout << "The square is:" << nSq << endl;
}
INTEGER*4 CSTR(1)
M=N*N
WRITE(6,20) (CSTR(L),L=1,3)
20 FORMAT(' CSTR=',3A4)
WRITE(6,*) 'DONE'
RETURN
END
xilink: executing 'link'
Microsoft Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
fr.obj
c.obj : error LNK2001: unresolved external symbol _FR1@12
c.exe : fatal error LNK1120: 1 unresolved externals
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_FR1@16' :: FR1Hope this helps.
- 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
No -- Intel Fortran changed the default calling convention from __stdcall to __cdecl. It should work if you change the prototype to __cdecl. I'm not sure what happened with case (whether it's uppercase or lowercase) -- try "fr1" instead.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That looks more like f66 than f90. No matter, it will be fun mixing extended f66 with C++. You have already demonstrated on of the pitfalls of Microsoft-specific calling conventions; they change every 2 or 3 years, a mere moment considering that you are using a 30 year old programming style. A more portable way would be simply to use
extern "C" FR1(...
Then you could run dumpbin /symbols on both Fortran and C++ .obj files, to see if you need any adjustments on the C++ side.
To me, it's more than a little strange to pass a char*, treat it as a pointer to an array of 1 32-bit integer, then access out of bounds, using f66 notation.
You also create huge difficulties for yourself, attempting to write to stdout with 2 conflicting run-time libraries.
![](/skins/images/872293744008A34B36F8ABF94A46CC66/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page