#ifndef __MY_DLL_H__
#define __MY_DLL_H__
extern "C" {
__declspec(dllexport) int test_add(int a, int b);
};
#endif
新建源文件my_dll.cpp
#include "pch.h"
#include "my_dll.h"
#include <stdio.h>
int test_add(int a, int b)
{
int m;
m = a + b;
printf("a: %d, b: %d. m: %d\n", a, b, m);
return m;
}
#include <iostream>
#include "my_dll.h"
int main()
{
int a, b, max;
a = 50;
b = 100;
max = test_add(a, b);
printf("max=%d\n", max);
std::cout << "Hello World!\n";
}