UINT64_C

如题,我们在使用Eclipse for C++时,通过增加定义-D__STDC_CONSTANT_MACROS, 可以使编译通过,但CDT的智能提示却总是报错, 通过一番查找,在stdint.h头文件中发现了它的定义:

  1. /* The ISO C99 standard specifies that in C++ implementations these 
  2.    should only be defined if explicitly requested.  */  
  3. #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS  
  4.   
  5. /* Signed.  */  
  6. # define INT8_C(c)  c  
  7. # define INT16_C(c) c  
  8. # define INT32_C(c) c  
  9. # if __WORDSIZE == 64  
  10. #  define INT64_C(c)    c ## L  
  11. # else  
  12. #  define INT64_C(c)    c ## LL  
  13. # endif  
  14.   
  15. /* Unsigned.  */  
  16. # define UINT8_C(c) c  
  17. # define UINT16_C(c)    c  
  18. # define UINT32_C(c)    c ## U  
  19. # if __WORDSIZE == 64  
  20. #  define UINT64_C(c)   c ## UL  
  21. # else  
  22. #  define UINT64_C(c)   c ## ULL  
  23. # endif  
  24.   
  25. /* Maximal type.  */  
  26. # if __WORDSIZE == 64  
  27. #  define INTMAX_C(c)   c ## L  
  28. #  define UINTMAX_C(c)  c ## UL  
  29. # else  
  30. #  define INTMAX_C(c)   c ## LL  
  31. #  define UINTMAX_C(c)  c ## ULL  
  32. # endif  
  33.   
  34. #endif  /* C++ && constant macros */  

主要是这一句:
  1. #if !defined __cplusplus || defined __STDC_CONSTANT_MACROS  
由于我们的工程是c++的,第一个条件不满足, 第二个条件就是我们在编译时加入的宏定义,出现如题的错误肯定是这个宏定义了,但没有被智能识别程序识别。

解决方案:

1. 右键单击 c++ 工程,Properties>>C/C++ General>>Paths and Symbols>>Symbols>>GNU C++>>Add

2. 在弹出的对话框中输入Name:__STDC_CONSTANT_MACROS Values: 1

再到程序中按F3,是不是可以找到UINT64_C了?


通过此方法,你可以增加其它的宏,以供智能识别程序识别。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值