gmp (gnu multiprecision) 라이브러리를 쓸 일이 있어서 메뉴얼과 헤더파일을 보던 중 재밌는 코드를 발견!
{
int _mp_alloc; /* Number of *limbs* allocated and pointed
to by the _mp_d field. */
int _mp_size; /* abs(_mp_size) is the number of limbs the
last field points to. If _mp_size is
negative this is a negative number. */
mp_limb_t *_mp_d; /* Pointer to the limbs. */
} __mpz_struct;
typedef __mpz_struct mpz_t[1];
이 부분에 대해서 메뉴얼은 다음과 같이 설명하고 있다.
이 정의를 활용하는 코드를 보면 다음과 같다.
foo (mpz_t result, const mpz_t param, unsigned long n)
{
unsigned long i;
mpz_mul_ui (result, param, n);
for (i = 1; i < n; i++)
mpz_add_ui (result, result, i*7);
}
int
main (void)
{
mpz_t r, n;
mpz_init (r);
mpz_init_set_str (n, “123456”, 0);
foo (r, n, 20L);
gmp_printf (“%Zd\n”, r);
return 0;
}
이렇게 선언해 놓고 참조하면 자연스럽게 함수 호출할 때 call-by-reference가 가능하다. c언어의 묘미란 이런게 아닐까?








첫번째 상품은 ava Sleevz for MacBook으로 네이버 쇼핑 최저가 15,190원이다. 맥북을 타겟으로 만든 슬리브기 때문에 사이즈가 정확히 맞으며 심플하고 깔끔하다는 장점이 있지만 충격 흡수 기능은 거의 없다고 봐도 무방할 듯 하다. 회사에서 사택까지의 거리가 도보로 10분인 것을 감안한다면 한손에 끼고 조심스럽게 돌아다니면 큰 무리는 없을 듯 한데 아무래도 불안함을 지울 수 없을 듯. 