On 8/3/19 2:17 PM, Gerald Pfeifer wrote:
Building with clang 7 or new versions of GCC I get the loads of the following under dlls/msi:
winemsi_s.c:4014:5: warning: cast between incompatible calling conventions 'cdecl' and 'stdcall'; calls through this pointer may abort at runtime [-Wcast-calling-convention] (SERVER_ROUTINE)s_remote_ViewClose, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./winemsi.h:69:14: note: consider defining 's_remote_ViewClose' with the 'stdcall' calling convention UINT __cdecl s_remote_ViewClose( ^ __attribute__((stdcall))
Does the approach below look proper? If not, how would you address this?
So, from my understanding:
* MIDL always generates functions not decorated by calling convention, unless one is explicitly specified (I think? I haven't tested this.)
* Microsoft says the default calling convention in C/C++ is cdecl [1], so the RPC runtime must presumably expect those functions to be cdecl.
* For stubless mode, I think it doesn't matter which calling convention is used (at least between cdecl and stdcall), since the caller can just clean up the stack, as we do in call_server_func().
* I don't think the server routine table is used when not using stubless mode. (Are we even correct to generate it in that case?)
Personally, I'm inclined to say this warning is not very useful in general, and should be ignored. I don't think it's any more an error to mismatch calling convention than, say, parameter count or type, when casting a function. But of course it's not my decision to make.
[1] https://docs.microsoft.com/en-us/cpp/cpp/cdecl?view=vs-2019