动态链接库的制作:
Windows桌面向导-应用程序类型:动态链接库(.dll) 空项目 MyDynamicLib
头文件声明函数时,在前面加上 extern "C" __declspec(dllexport)
1 //MyDynamicLib.h 2 #pragma once 3 extern "C" __declspec(dllexport) int GetMaxCommDiv(int a, int b); 4 extern "C" __declspec(dllexport) int GetMinCommMul(int a, int b);
1 //MyDynamicLib.cpp 2 #include "MyDynamicLib.h" 3 4 int GetMaxCommDiv(int a, int b) 5 { 6 int x = 1; 7 int ires; 8 if (a < b) 9 return 0; 10 if (b == 0) 11 return 0; 12 while (x != 0) 13 { 14 x = a % b; 15 a = b; 16 ires = b; 17 b = x; 18 } 19 return ires; 20 } 21 22 int GetMinCommMul(int a, int b) 23 { 24 int x = 1; 25 int ires; 26 int m, n; 27 m = a; n = b; 28 if (a < b) 29 return 0; 30 if (a == 0) 31 return 0; 32 if (b == 0) 33 return 0; 34 while (x != 0) 35 { 36 x = a % b; 37 a = b; 38 ires = b; 39 b = x; 40 } 41 ires = (m * n) / ires; 42 return ires; 43 }
标签:__,return,declspec,int,ires,C++,dll,实例,MyDynamicLib From: https://www.cnblogs.com/kaling/p/17118896.html