Re: [Dar-discussions] Re: problem testing infinint value

Johnathan Burchill <[email protected]> Thu, 24 Jun 2004 16:01:43 -0600
Newsgroups gmane.comp.sysutils.backup.dar.libdar
Organization Department of Physics and Astronomy, University of Calgary
Message-ID <[email protected]>
On June 24, 2004 01:36 pm, Denis Corbin wrote:

> Johnathan Burchill wrote:
> > Hi Denis,
>
> hello Johnathan,
>
> > This code has worked up until now.
> >
> > 		QString plural("s ");
> > 		libdar::statistics st=op_test(theArchive, selection, subtree,
> > verbose); if (st.errored == libdar::infinint(1)) plural = " ";
> >
> > It compiles fine (dar-2.1.3), but I get the following linker error:
> >
> >[...]
> >
> > *testArchiveThread.o(.text+0x2dd): In function
> > `testArchiveThread::run()': *: undefined reference to `void
> > libdar::limitint<unsigned long long>::limitint_from<long>(long)'
> > *collect2: ld returned 1 exit status
> > *Making all in doc
> > *gmake[2]: *** [kdar] Error 1
> > *gmake[2]: Target `all' not remade because of errors.
> > *
> >
> > The only change was to put the code into a separate .cpp file, which
> > compiles okay. When the code was inside my kdar.cpp file, there was no
> > problem during linkage.
>
> Have you checked the files included in kdar.cpp against those included
> in your separated file ? Has the compiler been changed ?

Ah! The missing code was

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

And it has to be at the beginning of the .cpp files.
Thanks for the suggestion!

[...]

>
> for what it seems, the constant '1' in the expression, is cast as "long"
> before being given to the limitint constructor. This is wrong because
> there limitint is *unsigned* and cannot be built from *signed* integers.

[...]
>
> To fix the problem, I suggest an explicit cast:
>
> 	if (st.errored == libdar::infinint((U_I)1) plural = " ";
>
> U_I is a libdar macro, system independent, matching an unsigned integer.
> (see "libdar/integers.hpp"), but if you prefer you can safely replace it
> by "unsigned int".

Signed long integers I can pass to the infinint constructor, and it work 
okay. They must get cast implicitly by the library.

[...]

> Cheers,
> Denis.
>
> P.S.: it should be more appropriate to post to lidar-api mailing-list
> rather than to this general discussion mailing-list for such problems.
> Thanks.

No problem --- I should have considered this in the first place.

[...]

Cheers,
JB

-- 
Johnathan K. Burchill, Ph.D.
Department of Physics and Astronomy
University of Calgary
2500 University Drive N.W.
Calgary, AB T2N 1N4
Canada

(403) 217-4286
[email protected]
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQBA209MrXMSOtiWrO4RAmlkAKCcXp4kIHaDwIVEohr8tkRfTo8qagCfY3n3
obz9VbSmSgveqbBMf0X6lhA=
=dzNp
-----END PGP SIGNATURE-----