Document of c-modernization-kit (calc) 1.0.0
Loading...
Searching...
No Matches
calcHandler.c File Reference

calcHandler 関数の実装ファイル。 More...

#include <libcalc.h>
#include <libcalcbase.h>
#include <stddef.h>
Include dependency graph for calcHandler.c:

Go to the source code of this file.

Functions

int CALC_API calcHandler (const int kind, const int a, const int b, int *result)
 指定された演算種別に基づいて計算を実行します。

Detailed Description

calcHandler 関数の実装ファイル。

Author
c-modenization-kit sample team
Date
2025/11/22
Version
1.0.0

演算種別に基づいて適切な計算関数を呼び出すハンドラーを提供します。

Definition in file calcHandler.c.

Function Documentation

◆ calcHandler()

int CALC_API calcHandler ( const int kind,
const int a,
const int b,
int * result )

指定された演算種別に基づいて計算を実行します。

Parameters
[in]kind演算の種別 (CALC_KIND_ADD など)。
[in]a第一オペランド。
[in]b第二オペランド。
[out]result計算結果を格納するポインタ。
Returns
成功時は CALC_SUCCESS、失敗時は CALC_SUCCESS 以外の値を返します。

この関数は演算種別を受け取り、対応する計算関数を呼び出します。 現在サポートされている演算種別は以下の通りです。

演算種別 説明
CALC_KIND_ADD 加算を実行
CALC_KIND_SUBTRACT 減算を実行
CALC_KIND_MULTIPLY 乗算を実行
CALC_KIND_DIVIDE 除算を実行
使用例
int result;
if (calcHandler(CALC_KIND_ADD, 10, 20, &result) == CALC_SUCCESS) {
printf("Result: %d\n", result); // 出力: Result: 30
}
CALC_EXPORT int CALC_API calcHandler(const int kind, const int a, const int b, int *result)
指定された演算種別に基づいて計算を実行します。
Definition calcHandler.c:21
#define CALC_SUCCESS
成功の戻り値を表す定数。
#define CALC_KIND_ADD
加算の演算種別を表す定数。
Warning
無効な kind を指定した場合、ゼロ除算の場合、 または result が NULL の場合は失敗を返します。 呼び出し側で戻り値のチェックを行ってください。

Definition at line 21 of file calcHandler.c.

References add(), CALC_API, CALC_ERROR, CALC_KIND_ADD, CALC_KIND_DIVIDE, CALC_KIND_MULTIPLY, CALC_KIND_SUBTRACT, divide(), multiply(), and subtract().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: