PInvokeStackImbalance C# call to unmanaged C++ function

前端 未结 5 1808
礼貌的吻别
礼貌的吻别 2020-12-05 00:09

After switching to VS2010, the managed debug assistant is displaying an error about an unbalanced stack from a call to an unmanaged C++ function from a C# application.

<
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 00:37

    You specify stdcall in C# but not in C++, a mismatch here will lead to both the function and the caller popping arguments off of the stack.

    On the other hand there is a compiler switch that will turn on stdcall as the default calling convention, (-Gz) are you using that?

    Or try this in your C++

    short __stdcall SuperSpecialOpenFileFunc(SuperSpecialStruct * stuff);
    

提交回复
热议问题