惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Forbes - Security
Forbes - Security
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
W
WeLiveSecurity
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
News and Events Feed by Topic
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
Engineering at Meta
Engineering at Meta
PCI Perspectives
PCI Perspectives
Martin Fowler
Martin Fowler
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
WordPress大学
WordPress大学
S
Security Affairs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
SegmentFault 最新的问题
P
Privacy International News Feed
IT之家
IT之家
M
MIT News - Artificial intelligence
G
GRAHAM CLULEY
Hacker News: Ask HN
Hacker News: Ask HN
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Check Point Blog
美团技术团队
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
宝玉的分享
宝玉的分享
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
爱范儿
爱范儿
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
I
InfoQ
N
News | PayPal Newsroom
TaoSecurity Blog
TaoSecurity Blog

博客园 - 秃头星AI

如果没有 Tools,Agent 什么都做不了 为什么 Agent 一定要“思考→行动→观察”?聊聊 ReAct 循环 当大模型开始控制设备:我是怎么理解 Agent 架构的 AI 真正的突破,不是更聪明,而是开始能「行动」 Prompt 一旦超出上下文窗口,该怎么办? 别再把 RAG 当搜索:它本质上是在重构 Context 你以为AI记住了你,其实没有:大模型记忆机制拆解 看见,才会回答:Context 如何重塑 AI 的能力边界 你以为在给 AI 下命令,其实你在改写它的概率分布 AI真的会思考吗?当我们拆开大语言模型,看到的是一个完全反直觉的真相 三、控制权之争:从 Workflow 到 Claude Skills,AI 正在进入「执行契约时代」 二、LLM进化史:从“复读机”到“牛马员工”,Agent到底是个什么鬼? 一、大语言模型上班记:从只会接话到会查资料的进化史 .Net 使用 Consul Consul Windows部署 C#/C++ 通过ODBC连接OceanBase Oracle租户 线程同步构造 C# lock 和 Monitor C#调用C++ (使用C++/CLI)
C++调用C# (使用C++/CLI)
秃头星AI · 2024-03-25 · via 博客园 - 秃头星AI

简介

C++/CLI简介见上文 C#调用C++ (使用C++/CLI) - 咸鱼翻身? - 博客园 (cnblogs.com)

新建解决方案->CPlusCSharpSolution

新建C#类库->CSharpNative

新建类NativeCalculate

1     public class NativeCalculate
2     {
3         public int Add(int a, int b)
4         {
5             return a + b;
6         }
7     }

新建CLI类库(DLL)->CSharpWrapper

 添加CSharpNative引用

 添加NativeCSharpWrapper类

//NativeCSharpWrapper.h

#pragma once

using namespace System;

namespace CSharpWrapper {
    public ref class NativeCSharpWrapper
    {
        public:
        static int Add(int a, int b);
    };
}

//NativeCSharpWrapper.cpp

#include "pch.h"

#include "NativeCSharpWrapper.h"

using namespace CSharpWrapper;
using namespace CSharpNative;

int NativeCSharpWrapper::Add(int a, int b) {
    int sum = 0;
    NativeCalculate^ nativeCalculate = gcnew NativeCalculate(); // 创建C#类的实例
    sum = nativeCalculate->Add(a, b); // 调用C#方法
    return sum;
}

创建非托管类NativeCSharpWrapper 

创建非托管类调用NativeCSharpWrapper 并提供对外导出

//NativeCalculate.h

#pragma once
#ifndef NATIVE_CLASS_H
#define NATIVE_CLASS_H

class __declspec(dllexport) CPlusCalculate {
public:
    static int Add(int a, int b);
};
#endif // NATIVE_CLASS_H
 
// NativeCSharpWrapper.cpp

#include "pch.h"
#include "NativeCSharpWrapper.h"

using namespace CSharpWrapper;
using namespace CSharpNative;

int NativeCSharpWrapper::Add(int a, int b) {
    int sum = 0;
    NativeCalculate^ nativeCalculate = gcnew NativeCalculate(); // 创建C#类的实例
    sum = nativeCalculate->Add(a, b); // 调用C#方法
    return sum;
}

新建C++控制台项目->CPlusConsoleApplication

添加包含目录 CSharpWrapper.h

添加CSharpWrapper.lib附加库目录

添加附加库依赖项CSharpWrapper.lib

main函数调用

main函数调用C++/CLI项目CSharpWrapper进而调用CSharpNative

#include <iostream>
#include "CPlusCalculate.h"
int main()
{
    int sum = CPlusCalculate::Add(50, 40);
}