unsigned long long类型匹配问题

brunodl 2012-06-29 01:18:59
#define A 0x0002000000000000
#define B 0x0003000000000000

typedef struct {
unsigned long long value1;
unsigned long long value2;
}test;

test test_array[] = { { A ,B}};


这个为什么总是提示integer constant is too large for ‘long’ type
...全文
297 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
brunodl 2012-06-29
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
也可以试试
#define A 0x0002000000000000llu
#define B 0x0003000000000000llu
[/Quote]
这样之后没警告了,谢谢
赵4老师 2012-06-29
  • 打赏
  • 举报
回复
也可以试试
#define A 0x0002000000000000llu
#define B 0x0003000000000000llu


brunodl 2012-06-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
vs2008 通过。
你用的编译器太旧了吧,不支持long long
[/Quote]

我这个是在windows下的虚拟机ubuntu里,用eclipse编译的,一直提示这个错误
赵4老师 2012-06-29
  • 打赏
  • 举报
回复
#define A 0x0002000000000000uI64
#define B 0x0003000000000000uI64

C++ Integer Constants
Integer constants are constant data elements that have no fractional parts or exponents. They always begin with a digit. You can specify integer constants in decimal, octal, or hexadecimal form. They can specify signed or unsigned types and long or short types.

Syntax

integer-constant :

decimal-constant integer-suffixopt
octal-constant integer-suffixopt
hexadecimal-constant integer-suffixopt
'c-char-sequence'

decimal-constant :

nonzero-digit
decimal-constant digit

octal-constant :

0
octal-constant octal-digit

hexadecimal-constant :

0x hexadecimal-digit
0X hexadecimal-digit
hexadecimal-constant hexadecimal-digit

nonzero-digit : one of

1 2 3 4 5 6 7 8 9

octal-digit : one of

0 1 2 3 4 5 6 7

hexadecimal-digit : one of

0 1 2 3 4 5 6 7 8 9
a b c d e f
A B C D E F

integer-suffix :

unsigned-suffix long-suffixopt
long-suffix unsigned-suffixopt

unsigned-suffix : one of

u U

long-suffix : one of

l L

64-bit integer-suffix :

i64



CandPointer 2012-06-29
  • 打赏
  • 举报
回复
放弃使用微软的编译器,这种编译器,
C99不支持,也就是 long long 不支持(VS2010也不支持,未来也没有计划支持c99)
c++ 0x 的支持度也比较差。

换用gcc, 或者收费的很好的Intel Parallel studio
薛定谔之死猫 2012-06-29
  • 打赏
  • 举报
回复
在有些编译器实现中,long long就是long,不必在折腾~
  • 打赏
  • 举报
回复
vs2008 通过。
你用的编译器太旧了吧,不支持long long

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧