Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

stdcall calling convention for COM stuff

$
0
0

My understanding is that the stdcall calling convention specifies that returned objects of eight bytes or less in size are passed back through the EAX and EDX registers. 

However, if the function is a non-static member of a C++ class, MS VC++ appears to use a hidden pointer argument in order to return aggregate types, regardless of the size of the returned aggregate.  (Note the use of the word "appears" - I have no idea what is really supposed to happen.)

Is there a way to tell ifort that an otherwise stdcall function should always use this hidden parameter approach?  At the moment, I seem to get by by declaring the "function" as a subroutine, and explicitly including the returned thing as the second argument passed by reference.  Is this robust?

This approach also seems to work on x64.  Thoughts?

The issue has arisen when trying to write Fortran bindings for the Direct2D API.  Yes, I have run out of pills.  That API includes a handy method ID2D1RenderTarget::GetSize that returns an aggregate D2D1_SIZE_F that is simply comprised of two float's.

The Microsoft provided C interface for that particular API has the same issue as a Fortran function binding - generated code expects the size to come back in EAX and EDX and (on x86 at least) expects the called thing to execute a RET 4 instruction (the actual API appears to execute a RET 8 - four bytes for the pointer to the "this" object, four bytes for the hidden address).  I guess the number of people writing pure C interfaces to Direct2D is probably equal to the number of people writing Fortran interfaces, minus one.  And people think Fortran is dead.  While oggling around this topic I see bug reports filed against other compilers for other languages that are probably due to this difference.

 


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>