码迷,mamicode.com
首页 > 编程语言 > 详细

Google C++ 编程规范总结

时间:2014-10-06 19:05:10      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   文件   sp   div   c   on   

一、头文件

  1. #define 的保护

    项目 foo 中的头文件 foo/src/bar/baz.h 按如下方式保护:

    #ifndef FOO_BAR_BAZ_H_
    #define FOO_BAR_BAZ_H_
    ...
    #endif //FOO_BAR_BAZ_H_
    #ifdef WINDOWS #define MYTYPE long #else #define MYTYPE float #endif
    #ifndef WINDOWS #define MYTYPE long #else #define MYTYPE float #endif
    用于代码调试:
    #ifdef DEBUG 
    print ("device_open(%p) ", file); 
    #endif
    在它前面必须有:
    #define DEBUG
    起到一个开关作用。
  2. 内联函数

    不要内联超过 10 行的函数。

  3. 函数参数顺序

    定义函数时,输入参数在前,输出参数在后。

Google C++ 编程规范总结

标签:style   blog   color   ar   文件   sp   div   c   on   

原文地址:http://www.cnblogs.com/wubin91/p/4008402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!