I'm trying to create a function that returns type mpfr_t but I get an error in its declaration. The header file declaration looks like (mpfr.h is local):
#include "include/mpfr.h"
mpfr_t calcWinProb(int x);
But when I try to compile I get the following error:
error: âcalcWinProbâ declared as function returning an array
Any ideas?
C language does not allow array as return type, which
mpfr_tdefinitely is:Refering to N1570 (C11 draft)
6.7.6.3/1Function declarators (including prototypes):This is violation of constraint, thus your compiler is obligated for diagnostic (e.g. error on compilation).
Whay you may do about it is to replace
mpfr_twithmpfr_ptr(pointer to struct) type or redesign your declaration, sompfr_tis one of parameters (may be the first), rather then that return type, which might bevoidin such case. The latter solution seems to be more coherent with MPFR API.