编译中的第一个错误是
brg_types.h:138:6: error: #error Please define uint_64t as an unsigned 64 bit type in brg_types.h
Run Code Online (Sandbox Code Playgroud)
(之前只是可能指向问题的警告,但它们不会导致编译中断.)
问题在于没有定义BRG_UI64,更具体地说是类型uint_64t.该定义先前发生.存在以下大多数问题是因为没有定义uint_64t,所以原因相同.
本质上,它看起来是第一个具有最大值18446744073709551615u的第一个不同的无符号类型,即一个完整的无符号64位整数,并将其定义为uint_64t.如果未找到任何类型,则使用#error引发上述错误.
因此,远程系统上的UINT_MAX,ULONG_MAX,ULLONG_MAX或ULONG_LONG_MAX似乎都不是18446744073709551615.
您可以使用简单的程序检查常量的值
#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;
}
Run Code Online (Sandbox Code Playgroud)
我的系统上有几个版本的limits.h和climits(包括一些c ++ - 包括在内)(也许还有你的).你可以找到它们
find /usr/include -name '*limits*'
Run Code Online (Sandbox Code Playgroud)
无论如何,我无法帮助您移植图书馆.如果您不知道自己在做什么,我认为自己定义类型并不是一个好主意(尽管具有更大最大值的无符号整数类型可能有效).
如果不同的编译器没有为您解决问题,最好联系作者进行修复.
这些常量是系统和编译器相关的.因此,它在本地工作但不在远程计算机上工作的原因可能是:
以下是那些可能比我更深入了解平台相关内容的人的代码.
#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
Run Code Online (Sandbox Code Playgroud)