gpt4 book ai didi

c# - 将枚举类型引用从 C# 传递到 C++/CLI 包装器到 C++

转载 作者:太空狗 更新时间:2023-10-29 23:01:44 26 4
gpt4 key购买 nike

<分区>

我搜索了很多答案,但找不到。我有一个连接我的 c# 和我的 c++ 代码的 c++/CLI 包装器。我想传递一个指向参数的指针作为运行函数的输入参数的一部分,它将表示程序的状态。

在 C++ 中,我定义了一个枚举:枚举状态码{ 初始化、开始、CFG_STARTED、CFG_COMPLETED、STAGE1、STAGE2、DONE

我的 C# 代码中有相同的枚举:

   public enum statusCode
{
INIT, BEGIN, CFG_STARTED, CFG_COMPLETED, STAGE1, STAGE2, DONE
}

我在 C++ 代码中有一个运行函数,它获取指向状态的指针:void Run(statusCode* status);

在我使用的 C# 方面:

public static statusCode program_status = statusCode.INIT;
wrapper.Run(ref program_status);

现在在 C++/CLI 界面中我卡住了...

public ref class Wrapper 
{
public:
int run(System::String^ outputDir, statusCode% returnStatus);
}

在cpp文件中:

int CMSWrapper::run(statusCode% returnStatus)
{
errorCode ret;
ret = m_Controller->Run( static_cast<statusCode*>(returnStatus));
return ret;
}

我只是不知道如何声明 Run 函数以及如何在包装器 (CLI/C++) 中描述它

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com