Problem wth mpf_asprintf (GMP 4.1.x, Visual C/C++ 6, Windows XP)

Bruce M. Axtens bruce.axtens at
Fri Jul 17 06:26:01 CEST 2009

In the following code, |buff| ends up containing not the contents of 
|n1| but the address of it.

|#define F(x) mpf_t (x); mpf_init( (x) );
BSTR __stdcall FPRINT( BSTR p1, BSTR p2 ) { 

        char * buff;
        int i;

        LPSTR sNum = W2A( p1 );
        LPSTR sFmt = W2A( p2 );
        mpf_set_str( n1, sNum, 10 );
        i = gmp_asprintf( &buff, sFmt, n1 );
        BSTR bResult = _com_util::ConvertStringToBSTR( buff );
        return bResult;

for example, if I issue |FPRINT("1","%d")| (in VB6 via Typelib), I get 
|1309932| which is the address of the n1 variable.

Any ideas?

Kind regards,

More information about the gmp-discuss mailing list