- 论坛徽章:
- 0
|
#include "stdafx.h"
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define RecordGetOff(rec) \
( \
(uint64) (((rec)->off_hi << 32) | ((uint32) (rec)->off_lo)) \
)
#define BlockIdGetBlockNumber(blockId) \
( \
(uint32) (((blockId)->bi_hi << 16) | ((uint16) (blockId)->bi_lo)) \
)
typedef struct BlockIdData
{
uint16 bi_hi;
uint16 bi_lo;
} BlockIdData;
typedef struct XLogRecOff
{
uint32 off_hi;
uint32 off_lo;
} XLogRecOff;
int _tmain(int argc, _TCHAR* argv[])
{
BlockIdData test;
test.bi_hi = 2;
test.bi_lo = 3;
XLogRecOff test1;
test1.off_hi = 2;
test1.off_lo = 3;
printf("%u\n", BlockIdGetBlockNumber(&test));
printf("%llu\n", RecordGetOff(&test1));
return 0;
}
会报c:\documents and settings\administrator\my documents\visual studio 2005\projects\test\test\test.cpp(43) : warning C4293: “<<”: Shift 计数为负或过大,其行为未定义
结果为
131075
3
为什么对于16位的这样的操作是对的,而对于32位的同样操作就不行了?谢谢大家 |
|