登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

中吴南顾惟一笑

成功法则就是那19个字

 
 
 

日志

 
 

Google的C++编程规范里的几点  

2011-03-08 14:57:05|  分类: R&D |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml


Don't use an #include when a forward declaration would suffice.

Use streams only for logging.

Use 0 for integers, 0.0 for reals, NULL for pointers, and '\0' for chars.

Use sizeof(varname) instead of sizeof(type) whenever possible.

Use only spaces, and indent 2 spaces at a time.

Remember that sizeof(void *) != sizeof(int).

You may need to be careful with structure alignments, particularly for structures being stored on disk. Any class/structure with a int64_t/uint64_t member will by default end up being 8-byte aligned on a 64-bit system. If you have such structures being shared on disk between 32-bit and 64-bit code, you will need to ensure that they are packed the same on both architectures. Most compilers offer a way to alter structure alignment. For gcc, you can use __attribute__((packed)). MSVC offers #pragma pack() and __declspec(align()).

Use the LL or ULL suffixes as needed to create 64-bit constants. For example:
int64_t my_value = 0x123456789LL;
uint64_t my_mask = 3ULL << 48;

Do not use C++ exceptions.
  评论这张
 
阅读(232)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018