33 lines
551 B
C
33 lines
551 B
C
#include <stdio.h>
|
|
#include "maindll.h"
|
|
|
|
/*
|
|
Use this command to run
|
|
|
|
gcc -DBUILD_DLL -shared main.c -o calc.dll -Wl,--out-implib,libcalc.a
|
|
*/
|
|
|
|
|
|
int add(int a, int b){
|
|
return a + b;
|
|
}
|
|
int mul(int a, int b){
|
|
return a * b;
|
|
}
|
|
int sub(int a, int b){
|
|
return a - b;
|
|
}
|
|
int divd(int a, int b){
|
|
if(b == 0) return -1;
|
|
return a / b;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|