Files
workspace/c/3.c
e2hang ebcee63b7c New
2026-01-09 00:05:37 +08:00

40 lines
654 B
C

//Test For DLLs
#include <Windows.h>
/*
Use this command to run
gcc -shared 3.c -o calc.dll -Wl,--out-implib,libcalc.a
*/
#ifndef BUILD_DLL
#define API __declspec(dllexport)
#else
#define API __declspec(dllimport)
#endif
API int add(int a, int b){
return a + b;
}
API int mul(int a, int b){
return a * b;
}
API int sub(int a, int b){
return a - b;
}
API int divd(int a, int b){
if(b == 0) return -1;
return a / b;
}
API int calc(int a, int b, char op){
switch(op){
case '+': return add(a, b);
case '-': return sub(a, b);
case '*': return mul(a, b);
case '/': return divd(a, b);
}
}