I have been compiling brian gladman's library from here www.gladman.me.uk I am able to compile the lib on my local machine(ubuntu 10.10) but when I try to compile on my remote machine(CentOs 5.4) it generates numerous errors with gcc ..
The error generated ar开发者_StackOverflow中文版e here
thankx in adv ..
The first error in your compilation is
brg_types.h:138:6: error: #error Please define uint_64t as an unsigned 64 bit type in brg_types.h
(before are only warnings which might point to problems, but they don't cause your compile to break.)
The problem there is that BRG_UI64 was not defined, more specifically the type uint_64t. The definition takes place previously. Most of the following problems exist because uint_64t is not defined, so the same reason.
Essentially it looks among different unsigned types for the first that has a max value of 18446744073709551615u, i.e. a complete unsigned 64bit integer and defines that as uint_64t. If no type is found the above error is raised by using #error.
So it seems neither of UINT_MAX, ULONG_MAX, ULLONG_MAX or ULONG_LONG_MAX is 18446744073709551615 on your remote system.
You can check the values of your constants with a simple program
#include <limits.h>
#include <stdio.h>
int main()
{
double d;
#if defined( UINT_MAX )
d = UINT_MAX;
printf("UINT_MAX is %f\n", d );
#if UINT_MAX == 18446744073709551615u
printf("UINT_MAX satisfies condition\n");
#endif
#endif
#if defined( ULONG_MAX )
d = ULONG_MAX;
printf("ULONG_MAX is %f\n", d );
#if ULONG_MAX == 18446744073709551615ul
printf("ULONG_MAX satisfies condition\n");
#endif
#endif
#if defined( ULLONG_MAX )
d = ULLONG_MAX;
printf("ULLONG_MAX is %f\n", d );
#if ULLONG_MAX == 18446744073709551615ull
printf("ULLONG_MAX satisfies condition\n");
#endif
#endif
#if defined( ULONG_LONG_MAX )
d = ULONG_LONG_MAX;
printf("ULONG_LONG_MAX is %f\n", d );
#if ULONG_LONG_MAX == 18446744073709551615ull
printf("ULONG_LONG_MAX satisfies condition\n");
#endif
#endif
return 0;
}
There are several versions of limits.h and climits (which is included by some of the c++-includes) on my system (and perhaps on yours as well). You can find them with
find /usr/include -name '*limits*'
I can't help you porting the library anyway. I don't think defining a type on your own is a good idea if you don't know what you are doing (though an unsigned integer type with a bigger max value might work).
If a different compiler doesn't solve the problem for you it is probably best if you contact the author for a fix.
Those constants are system and compiler-dependent. So reasons why it works on your local, but not on the remote machine might be:
- One is a 32-bit machine, the other 64-bit
- Different version of gcc
- Ubuntu and CentOS install a different limit.h
Here is the code for those who might have more insight into those platform dependent stuff than me.
#include <limits.h>
...
#ifndef BRG_UI64
# if defined( __BORLANDC__ ) && !defined( __MSDOS__ )
# define BRG_UI64
# define li_64(h) 0x##h##ui64
typedef unsigned __int64 uint_64t;
# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */
# define BRG_UI64
# define li_64(h) 0x##h##ui64
typedef unsigned __int64 uint_64t;
# elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
# elif defined( __MVS__ )
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned int long long uint_64t;
# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u
# if UINT_MAX == 18446744073709551615u
# define BRG_UI64
# define li_64(h) 0x##h##u
typedef unsigned int uint_64t;
# endif
# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u
# if ULONG_MAX == 18446744073709551615ul
# define BRG_UI64
# define li_64(h) 0x##h##ul
typedef unsigned long uint_64t;
# endif
# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u
# if ULLONG_MAX == 18446744073709551615ull
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
# endif
# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u
# if ULONG_LONG_MAX == 18446744073709551615ull
# define BRG_UI64
# define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
# endif
# endif
#endif
The first error is on brg_types.hat line 138;
brg_types.h:138:6: error: #error Please define uint_64t as an unsigned 64 bit type in brg_types.h
I found here a online copy of that file (maybe a different version). So you need to find how to create a 64 bit unsigned integer, and add some defines above that line, for example
#define BRG_UI64
#define li_64(h) 0x##h##ull
typedef unsigned long long uint_64t;
if unsigned long long
is 64 bit and you enter literal numbers like 0x123456789ull
.
And it looks like there will be more porting required to compile this on your compiler.
精彩评论