Document of c-modernization-kit (calc) 1.0.0
Loading...
Searching...
No Matches
calcHandler.c
Go to the documentation of this file.
1
15
16#include <libcalc.h>
17#include <libcalcbase.h>
18#include <stddef.h>
19
20/* doxygen コメントは、ヘッダに記載 */
21int CALC_API calcHandler(const int kind, const int a, const int b, int *result)
22{
23 if (result == NULL)
24 {
25 return CALC_ERROR;
26 }
27
28 switch (kind)
29 {
30 case CALC_KIND_ADD:
31 return add(a, b, result);
33 return subtract(a, b, result);
35 return multiply(a, b, result);
37 return divide(a, b, result);
38 default:
39 return CALC_ERROR;
40 }
41}
int CALC_API calcHandler(const int kind, const int a, const int b, int *result)
指定された演算種別に基づいて計算を実行します。
Definition calcHandler.c:21
計算ライブラリ (動的リンク用) のヘッダーファイル。
#define CALC_API
呼び出し規約マクロ。
Definition libcalc.h:46
#define CALC_KIND_MULTIPLY
乗算の演算種別を表す定数。
#define CALC_KIND_SUBTRACT
減算の演算種別を表す定数。
#define CALC_KIND_DIVIDE
除算の演算種別を表す定数。
#define CALC_KIND_ADD
加算の演算種別を表す定数。
#define CALC_ERROR
失敗の戻り値を表す定数。
計算ライブラリ (静的リンク用) のヘッダーファイル。
int subtract(const int a, const int b, int *result)
2 つの整数を減算します。
Definition subtract.c:20
int divide(const int a, const int b, int *result)
2 つの整数を除算します。
Definition divide.c:20
int multiply(const int a, const int b, int *result)
2 つの整数を乗算します。
Definition multiply.c:20
int add(const int a, const int b, int *result)
2 つの整数を加算します。
Definition add.c:20