I just installed the gmp Multiple Precision Arithmetic Library on my mac. Whenever I compile a program, I get this warning:
warning: implicit declaration of function '__gmpz_out_str' is
invalid in C99 [-Wimplicit-function-declaration]
mpz_out_str(stdout,10,p);
/usr/local/include/gmp.h:951:21: note: expanded from macro 'mpz_out_str'
#define mpz_out_str __gmpz_out_str
I will get an executable that works, but I always get this when I use this particular function. Here is what the main file looks like:
#include <gmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
void fact(int n){
int i;
mpz_t p;
mpz_init_set_ui(p,1); /* p = 1 */
for (i=1; i <= n ; ++i){
mpz_mul_ui(p,p,i); /* p = p * i */
}
printf ("%d! = ", n);
mpz_out_str(stdout,10,p);
mpz_clear(p);
}
int main(int argc, char * argv[]){
int n;
if (argc <= 1){
printf ("Usage: %s <number> \n", argv[0]);
return 2;
}
n = atoi(argv[1]);
assert( n >= 0);
fact(n);
return 1;
}
Anyone know what the issue is?