动态库创建调用(四)

工作记录

在 动态库创建调用(二) 基础上修改

1. 在main.cpp 中添加全局变量  

   完成代码如下:

#include <Windows.h>
#include <iostream>
#include "D:\Dll1\MydllAdd.h"    //    包含头文件

#pragma comment(lib,"D:\\Dll1\\x64\\Debug\\Dll1.lib")  // 添加依赖项

API_DECLSPEC map <int, int>  globalmap;

int main()
{
    
    int a = 2, b = 3;
    int c = my_dll_add(a, b);

    // 查看map中数据 
    map <int, int>::iterator iterator_data;
    iterator_data = globalmap.find(1);
    int temp = iterator_data->first;

    std::cout << "my_dll_add(" << a << "," << b << ") = " << c << std::endl;
    return 0;
}

 

完成测试

遇到问题见 动态库创建调用(五)

posted @ 2022-07-15 16:04  SusieSnail_SUN  阅读(98)  评论(0)    收藏  举报