本机 Nuget 中的 cdecl 和 stdcall 调用约定 [英] cdecl and stdcall calling conventions in Native Nuget

查看:64
本文介绍了本机 Nuget 中的 cdecl 和 stdcall 调用约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个原生 nuget 包,该包提供调用约定的枢纽,为 x86 构建提供具有 cdecl 和 stdcall 约定的 DLL.(大多数用户更喜欢 cdecl 调用约定,但 P/Invoke 这个库的 .NET 用户出于各种原因更喜欢 stdcall.)

I'm trying to build a native nuget package that offers a pivot on calling conventions, providing DLLs with both cdecl and stdcall conventions for x86 builds. (Most users prefer cdecl calling conventions, but .NET users who P/Invoke this library would prefer stdcall for various reasons.)

我的 .autopkg 包含 cdecl 和 stdcall 枢轴:

My .autopkg contains both cdecl and stdcall pivots:

nuget
{
    [nuspec omitted for brevity]

    files {
            [Win32,cdecl] {
                lib: build\x86-cdecl\Debug\git2-0_21_0.lib;
                bin: build\x86-cdecl\Debug\git2-0_21_0.dll;
                symbols: build\x86-cdecl\Debug\git2-0_21_0.pdb;
            }

            [Win32,stdcall] {
                lib: build\x86-stdcall\Debug\git2-0_21_0.lib;
                bin: build\x86-stdcall\Debug\git2-0_21_0.dll;
                symbols: build\x86-stdcall\Debug\git2-0_21_0.pdb;
            }
    };
}

使用本机 nuget 脚本构建 .nupkg 似乎成功,并且在标准 C 项目(具有 cdecl 调用约定的项目)中安装和使用 nuget 包成功.

Building the .nupkg using the native nuget scripts appears to succeed and installing and using the nuget package within a standard C project (one with cdecl calling conventions) succeeds.

但是,如果我创建一个新的 C 项目并将调用约定设置为 stdcall 并安装 nuget 包,我将无法获得我的库的 stdcall 版本.相反,安装了 cdecl 版本,我无法链接.

However, if I create a new C project and set the calling conventions to stdcall and install the nuget package, I do not get the stdcall version of my library. Instead, the cdecl version is installed and I cannot link.

我很乐观地认为 nuget 包管理器会检测我的项目配置并使用适当的调用约定枢轴(就像它对处理器类型所做的那样),但这似乎并没有发生.我也没有提供手动选择调用约定的选项.然而,autopkg 配置中有一个枢轴这一事实让我觉得我可以选择一个.

I was optimistic that the nuget package manager would detect my project's configuration and use the appropriate calling convention pivot (like it does for the processor type), but that does not appear to happen. Nor am I given an option to select a calling convention manually. Yet the fact that there is a pivot in the autopkg configuration makes me think that I could select one.

我怎样才能利用这个支点?

How can I take advantage of this pivot?

推荐答案

据我所知,这是完全不可能的.遗憾的是,同样不可能获得帮助.

As best I can tell, this is completely impossible. It is, sadly, equally impossible to get help.

遗憾的是,Native Nuget 是一个几乎没有经过测试、几乎无法操作且完全没有支持的、错失良机的荒地.唯一的答案就是不使用它.

Native Nuget is, regrettably, a barely tested, almost inoperable and completely unsupported wasteland of missed opportunity. The only answer it to simply not use it.

这篇关于本机 Nuget 中的 cdecl 和 stdcall 调用约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆