简体   繁体   English

OpenWatcom / VisualStudio在调用约定中的互操作性

[英]OpenWatcom / VisualStudio interoperability in re calling conventions

I would like to compile a Photoshop Filter plugin with OpenWatcom. 我想用OpenWatcom编译一个Photoshop滤镜插件。 The code already exists and works perfectly with Visual Studio. 该代码已经存在,并且可以与Visual Studio完美配合。

The function looks like this: 该函数如下所示:

extern "C" __declspec(export) void PluginMain(short selector, FilterRecordPtr pb, intptr_t *data, short *result);

It works perfectly in Visual C++. 它在Visual C ++中可以完美地工作。 Note that there is explicitly no calling convention specified (Adobe does not define any calling convention in their SDK header files). 请注意,没有明确指定任何调用约定(Adobe在其SDK头文件中未定义任何调用约定)。

While it works in VC++, in OpenWatcom this does not work, and it seems like the calling convention is not correct. 尽管它在VC ++中有效,但在OpenWatcom中却不起作用,并且似乎调用约定不正确。 (I get weird behavior like corrupted stack, even with a "HelloWorld"-function). (即使使用“ HelloWorld”功能,我也会得到奇怪的行为,如损坏的堆栈)。

At Wikipedia, I have looked at the table with the calling conventions: The table says that if no calling convention is specified, Watcom puts parameters in registers "EAX, EDX, EBX, ECX", stack filled right to left, and callee cleans the stack. 在Wikipedia上,我查看了具有调用约定的表该表说 ,如果未指定调用约定,则Watcom会将参数放入寄存器“ EAX,EDX,EBX,ECX”,堆栈从右向左填充,被调用方清除堆。 But the table does not say what Microsoft compilers do if no calling convention is specified. 但是,该表未说明如果未指定调用约定,Microsoft编译器会做什么。 I do think that Visual Studio uses a different calling convention as default. 我确实认为Visual Studio使用不同的调用约定作为默认值。 So I tried to specify __stdcall , __cdecl or __pascal in OpenWatcom, but it didn't help much. 于是,我就指定__stdcall__cdecl__pascal在OpenWatcom,但它并没有多大帮助。

One of my questions is, what exactly is Visual Studio's default calling convention if nothing is specified? 我的问题之一是,如果未指定任何内容,Visual Studio的默认调用约定到底是什么? What exactly will put into registers, in what direction on the stack, and who cleans the stack? 究竟将什么内容放入寄存器中,在堆栈上的哪个方向上,谁清理堆栈? I couldn't find this information anywhere. 我在任何地方都找不到此信息。

If I would know the exact behavior, I might be able to use the "#pragma aux" functionality in OpenWatcom to enforce a custom calling convention? 如果我知道确切的行为,我是否可以使用OpenWatcom中的“ #pragma aux”功能来实施自定义调用约定?

Or do you know something else I can try to fix the calling convention in OpenWatcom? 还是您知道我可以尝试在OpenWatcom中修复调用约定的其他内容?

(moving from a comment) (从评论中移出)

The default calling convention in Visual C++ is cdecl , although it can be changed through a command-line switch ( /Gd , /Gr , /Gv , /Gz ) . 尽管可以通过命令行开关( /Gd/Gr/Gv/Gz )进行更改 ,但Visual C ++中的默认调用约定为cdecl

Reading around, it seems like Watcom has a similar set of options as well - -ecc should set it to use cdecl by default. -ecc阅读一下,似乎Watcom也具有类似的选项集-ecc应该将其默认设置为使用cdecl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM