On 30 May 2014 22:27, leif <not.rea...@online.de> wrote: > Guillermo Ramírez wrote: > >> Hello Brian, >> >> >However, many people do run into problems when they build x64 >> >applications on Windows becasue they wrongly assume that long types have >> >64-bits when in fact these types have 32-bits on Windows. To obtain a >> >64-bit type 'long long' has to be used. >> >> >MPIR itself has two predefined (signed and unsigned) integer types - >> >mpir_si and mpir_ui - that avoid this problem by being defined as 32-bit >> >types on win32 and 64-bit types on x64. If these are used in building >> >applications, it is often be possible to avoid many (but not all) of the >> >issues that turn up in porting win32 applications to x64. >> >> Does the above mean that the user needs to change the mpirxx.h file to a >> specific >> arithmetic type? >> > > No. > > > I am trying to use the open source libDAI library and am having several >> errors and >> warnings with the mpirxx.h file, for instance: >> >> Error1error C4146: unary minus operator applied to unsigned type, result >> >> still unsigned >> C:\Program Files (x86)\Microsoft Visual Studio >> 12.0\VC\include\mpirxx.h1181GBP1 >> > > Line 118 really looks a bit weird; the minus should IMHO precede 'l': > > inline void __mpz_set_si_safe(mpz_ptr p, mpir_si l) > { > if(l < 0) > { > __mpz_set_ui_safe(p, -static_cast<mpir_ui>(l)); // line 118 >
I must admit, that does look like a bug to me. Well spotted! > mpz_neg(p, p); > } > else > __mpz_set_ui_safe(p, l); > // Note: we know the high bit of l is 0 so we could do slightly better > } > > > Warning18warning C4244: 'argument' : conversion from '__int64' to >> >> 'mpir_si', possible loss of data >> C:\Program Files (x86)\Microsoft Visual Studio >> 12.0\VC\include\mpirxx.h15431GBP1 >> > > Here my impression is that mpir_si is indeed defined to (just) 32 bits (=> > win32), otherwise the warning doesn't make sense: > > #ifdef MPIRXX_HAVE_LLONG > __gmp_expr(signed long long int l) { mpz_init_set_si(mp, l); } // line > 1543 > __gmp_expr(unsigned long long int l) { mpz_init_set_ui(mp, l); } > #endif > > On the other hand, there should be a warning for the next line as well > (assuming mpir_ui is also just 32 bits). > > > Probably MPIRXX_HAVE_LLONG shouldn't be defined in that case? (The > "logic" w.r.t. to that preprocessor variable is at least a bit confusing > IIRC.) > > > Brian will know better, as he has tested on (and maintains the) Windows > (version)... > > > -leif > > > -- > () The ASCII Ribbon Campaign > /\ Help Cure HTML E-Mail > > -- > You received this message because you are subscribed to the Google Groups > "mpir-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mpir-devel+unsubscr...@googlegroups.com. > To post to this group, send email to mpir-devel@googlegroups.com. > Visit this group at http://groups.google.com/group/mpir-devel. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "mpir-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to mpir-devel+unsubscr...@googlegroups.com. To post to this group, send email to mpir-devel@googlegroups.com. Visit this group at http://groups.google.com/group/mpir-devel. For more options, visit https://groups.google.com/d/optout.