forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

When to use C_EXTERNAL and STDCALL

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> KBase
View previous topic :: View next topic  
Author Message
silverfrost
Site Admin


Joined: 29 Nov 2006
Posts: 191
Location: Manchester

PostPosted: Sun Sep 05, 2004 6:46 pm    Post subject: When to use C_EXTERNAL and STDCALL Reply with quote

When calling functions in libraries created in other languages, you must specify which calling convention is used. The calling convention specifies whether the function name is 'decorated' and how the function arguments are dealt with. The two main calling conventions you will need to know about are cdecl (specified by C_EXTERNAL) and stdcall (specified by STDCALL)).

If you are using a function library built by someone else (e.g. the Win32 API) you will be told which calling convention to use (in the case of the Win32 API, it is stdcall). If you are building your own function library, then you must specify the calling convention yourself. In C/C++ you can do this using extern "C" to specify the C calling convention, or __stdcall to specify the stdcall calling convention. For example:

Code:

void sub(); // declares a function that cannot be called from fortran
extern "C" void sub(); // declares a function that can be called from fortran using C_EXTERNAL
void __stdcall sub(); // declares a function that can be called from fortran using STDCALL
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> KBase All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group