[1] 테스트용 소스 파일 test_main.cpp 의 내용:
#include <tommath.h>
#include <stdio.h>
int main() {
mp_int num;
mp_init(&num);
mp_set_int(&num, 12345);
printf("Number: %d\n", mp_get_int(&num));
mp_clear(&num);
return 0;
}
[2] 컴파일하기:
$ g++ test_main.cpp -o test_main -ltommath
test_main .cpp: In function 'int main()':
test_main .cpp:7:15: warning: 'mp_err mp_set_int(mp_int*, long unsigned int)' is deprecated: replaced by mp_set_ul [-Wdeprecated-declarations]
7 | mp_set_int(&num, 12345);
| ~~~~~~~~~~^~~~~~~~~~~~~
In file included from test_tommath_cpp_001.cpp:1:
include/tommath.h:359:33: note: declared here
359 | MP_DEPRECATED(mp_set_ul) mp_err mp_set_int(mp_int *a, unsigned long b);
| ^~~~~~~~~~
test_tommath_cpp_001.cpp:8:38: warning: 'long unsigned int mp_get_int(const mp_int*)' is deprecated: replaced by mp_get_mag_u32/mp_get_u32 [-Wdeprecated-declarations]
8 | printf("Number: %d\n", mp_get_int(&num));
| ~~~~~~~~~~^~~~~~
include/tommath.h:356:56: note: declared here
356 | MP_DEPRECATED(mp_get_mag_u32/mp_get_u32) unsigned long mp_get_int(const mp_int *a) MP_WUR;
| ^~~~~~~~~~
test_tommath_cpp_001.cpp:6:12: warning: ignoring return value of 'mp_err mp_init(mp_int*)' declared with attribute 'warn_unused_result' [-Wunused-result]
6 | mp_init(&num);
| ~~~~~~~^~~~~~
[3] 수정된 소스 파일 test_main.cpp 의 내용:
#include <stdio.h>
#include <tommath.h>
int main() {
mp_int num;
mp_err err_n = mp_init(&num);
mp_set_i32(&num, 12345); // <== mp_set_int(&num, 12345);
printf("Number: %d\n", mp_get_i32(&num)); // <== printf("Number: %d\n", mp_get_int(&num));
mp_clear(&num);
return 0;
}
[4] 수정된 소스 파일 test_main.cpp 컴파일하기:
$ g++ test_main.cpp -o test_main -ltommath
[5] 생성된 실핼파일 test_main 을 실행한 결과 :
$ ./test_main
Number: 12345
'프로그래밍 > C' 카테고리의 다른 글
| C 언어에서 큰 부동소수점수(native double) 의 정확도 (0) | 2023.03.19 |
|---|---|
| MSYS2 에서 C 언어의 printf(...) 가 제대로 출력하지 못할 때... (0) | 2022.01.08 |
| Lanczos 계수를 이용하여 Gamma 함수값 구하기 (0) | 2021.12.08 |
| MPFR 라이브러리를 이용하여 Gamma 함수값 계산하기 (0) | 2021.01.28 |
| cygwin 의 gcc 로 UTF-8 한글 처리하는 간단한 예제 (0) | 2014.04.13 |