Contiki 源码风格
/**
* \defgroup coding-style Coding style
*
* This is how a Doxygen module is documented - start with a \defgroup
* Doxygen keyword at the beginning of the file to define a module,
* and use the \addtogroup Doxygen keyword in all other files that
* belong to the same module. Typically, the \defgroup is placed in
* the .h file and \addtogroup in the .c file.
*
* @{
*/ /**
* \file
* A brief description of what this file is.
* \author
* Adam Dunkels <adam@dunkels.com>
*
* Every file that is part of a documented module has to have
* a \file block, else it will not show up in the Doxygen
* "Modules" * section.
*/ /* Single line comments look like this. */ /*
* Multi-line comments look like this. Comments should prefferably be
* full sentences, filled to look like real paragraphs.
*/ #include "contiki.h" /*
* Make sure that non-global variables are all maked with the static
* keyword. This keeps the size of the symbol table down.
*/
static int flag; /*
* All variables and functions that are visible outside of the file
* should have the module name prepended to them. This makes it easy
* to know where to look for function and variable definitions.
*
* Put dividers (a single-line comment consisting only of dashes)
* between functions.
*/
/*---------------------------------------------------------------------------*/
/**
* \brief Use Doxygen documentation for functions.
* \param c Briefly describe all parameters.
* \return Briefly describe the return value.
* \retval 0 Functions that return a few specified values
* \retval 1 can use the \retval keyword instead of \return.
*
* Put a longer description of what the function does
* after the preamble of Doxygen keywords.
*
* This template should always be used to document
* functions. The text following the introduction is used
* as the function's documentation.
*
* Function prototypes have the return type on one line,
* the name and arguments on one line (with no space
* between the name and the first parenthesis), followed
* by a single curly bracket on its own line.
*/
void
code_style_example_function(void)
{
/*
* Local variables should always be declared at the start of the
* function.
*/
int i; /* Use short variable names for loop
counters. */ /*
* There should be no space between keywords and the first
* parenthesis. There should be spaces around binary operators, no
* spaces between a unary operator and its operand.
*
* Curly brackets following for(), if(), do, and case() statements
* should follow the statement on the same line.
*/
for(i = ; i < ; ++i) {
/*
* Always use full blocks (curly brackets) after if(), for(), and
* while() statements, even though the statement is a single line
* of code. This makes the code easier to read and modifications
* are less error prone.
*/
if(i == c) {
return c; /* No parentesis around return values. */
} else { /* The else keyword is placed inbetween
curly brackers, always on its own line. */
c++;
}
}
}
/*---------------------------------------------------------------------------*/
/*
* Static (non-global) functions do not need Doxygen comments. The
* name should not be prepended with the module name - doing so would
* create confusion.
*/
static void
an_example_function(void)
{ }
/*---------------------------------------------------------------------------*/ /* The following stuff ends the \defgroup block at the beginning of
the file: */ /** @} */
contiki/docs/code-style.c
一、模块 :
\defgroup 定义一个模块,一般在.h文件。
/** @} */ 和@{对应。
\addtogroup 加到某个模块,一般在.c文件。
/** @} */ 和@{对应。
\file 文件,每个需要生成文档的文件,都要添加这个标号。
/**
* \file
* A brief description of what this file is.
* \author
* Adam Dunkels <adam@dunkels.com>
*
* Every file that is part of a documented module has to have
* a \file block, else it will not show up in the Doxygen
* "Modules" * section.
*/
二、变量
不是全局变量的要添加static,限于该文件可见。
/*
* Make sure that non-global variables are all maked with the static
* keyword. This keeps the size of the symbol table down.
*/
static int flag;
局部变量要在函数statement之前定义
/*
* Local variables should always be declared at the start of the
* function.
*/
int i; /* Use short variable names for loop
counters. */
三、函数
函数或者变量,对外可见的话,要在函数名前添加模块名,这样可方便知道到哪查看函数或变量的定义。
函数和函数之间用一行只有-的注释来分隔开。
/*
* All variables and functions that are visible outside of the file
* should have the module name prepended to them. This makes it easy
* to know where to look for function and variable definitions.
*
* Put dividers (a single-line comment consisting only of dashes)
* between functions.
*/
/*---------------------------------------------------------------------------*/
函数原型及功能说明
返回值在一行
名字和参数在一行,第一个参数和 '(' 不用空格隔开
下一行为{
/**
* \brief Use Doxygen documentation for functions.
* \param c Briefly describe all parameters.
* \return Briefly describe the return value.
* \retval 0 Functions that return a few specified values
* \retval 1 can use the \retval keyword instead of \return.
*
* Put a longer description of what the function does
* after the preamble of Doxygen keywords.
*
* This template should always be used to document
* functions. The text following the introduction is used
* as the function's documentation.
*
* Function prototypes have the return type on one line,
* the name and arguments on one line (with no space
* between the name and the first parenthesis), followed
* by a single curly bracket on its own line.
*/
静态函数不用添加文档注释,也不要添加模块名字,因为静态函数只在本文件可见。
四、语句
关键词和第一个 ‘(’ 不用空格隔开
二元操作符要有空格隔开
一元操作符不用空格隔开
‘{’ 要和 if() for() do case() 等语句在同一行
在 if() for() while() 等语句后都要添加{},即使只有一行代码,方便阅读和后续修改。
else要被 } { 包围,并自同一行
/*
* There should be no space between keywords and the first
* parenthesis. There should be spaces around binary operators, no
* spaces between a unary operator and its operand.
*
* Curly brackets following for(), if(), do, and case() statements
* should follow the statement on the same line.
*/
for(i = ; i < ; ++i) {
/*
* Always use full blocks (curly brackets) after if(), for(), and
* while() statements, even though the statement is a single line
* of code. This makes the code easier to read and modifications
* are less error prone.
*/
if(i == c) {
return c; /* No parentesis around return values. */
} else { /* The else keyword is placed inbetween
curly brackers, always on its own line. */
c++;
}
}
}
Contiki 源码风格的更多相关文章
- Contiki源码+原理+功能+编程+移植+驱动+网络(转)
源:Contiki源码+原理+功能+编程+移植+驱动+网络 请链接:http://www.rimelink.com/nd.jsp? id=31&_np=105_315 假设您对于用Contik ...
- Contiki源码结构
Contiki源码结构 apps目录下,用于存放Application,也就是我们的应用程序放在这个目录下.如webserver,webrowser等,如下图所示. core目录是contiki操作系 ...
- contiki源码阅读之list
我们阅读一下contiki的源码,list.c(路径是./core/lib/list.h). #include "lib/list.h" #define NULL 0 struct ...
- Backbone源码风格
代码风格: 一.自执行匿名函数创建执行环境 var root = this; root保存全局执行环境的指针.浏览器端为window对象 二.依赖库 (1).underscore 如果bac ...
- Contiki源码分析--CPU为cc253x里的uart0.c
我所使用的Contiki系统是contiki-sensinode.理解该文需要有cc2530里uart的相关知识,具体寄存器的用法不做介绍. 先放上所有代码,然后再仔细分析. #include < ...
- contiki源码阅读之mmem.c
上次我们说了list,这次我们就借着mmem.c的代码来用一下这个链表. 代码目录是./core/lib/mmem.c 结构体定义如下 struct mmem { struct mmem *next; ...
- Google之Chromium浏览器源码学习——base公共通用库(一)
Google的优秀C++开源项目繁多,其中的Chromium浏览器项目可以说是很具有代表性的,此外还包括其第三开发开源库或是自己的优秀开源库,可以根据需要抽取自己感兴趣的部分.在研究.学习该项目前的时 ...
- 卡通风格的连连看ios游戏源码
卡通风格的连连看游戏源码,该游戏是一款韩国人做的卡通风格的ios连连看游戏源码,源码设计的效果非常漂亮的,而且运行起来感觉也很好.1.游戏采用倒计时模式2.该游戏是一款社交游戏,需要通过faceboo ...
- arcgis api 3.x for js 共享干货系列之二自定义 Navigation 控件样式风格(附源码下载)
0.内容概览 自定义 Navigation 控件样式风格 源码下载 1.内容讲解 arcgis api 3.x for js 默认的Navigation控件样式风格如下图:这样的风格不能说不好,各有各 ...
随机推荐
- 【Python】读取cvs文件报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 6: invalid start byte
现在有文件data.csv 文件编码格式为:ANSI data.csv 1|1|1|北京市 2|1|2|天津市 3|1|3|上海市 4|1|4|重庆市 5|1|5|石家庄市 6|2|5|唐山市 7|3 ...
- .NET实现爬虫
前几天看到一个.NET Core写成的爬虫,有些莫名的小兴奋,之前一直用集搜客去爬拉勾网的招聘信息,这个傻瓜化工具相当于用HTML模板页去标记DOM节点,然后在浏览器窗口上模拟人的浏览行为同时跟踪节点 ...
- SQL之相关语法及操作符
概述:UNION.SELECT INTO.INSERT INTO SELECT.SQL约束 UNION操作符 UNION操作符用于合并两个或多个SELECT语句的结果集 请注意,UNION内部的每个S ...
- 【Web API系列教程】3.10 — 实战:处理数据(公布App到Azure App Service)
在这最后一节中.你将把应用程序公布到Azure.在Solution Explorer中,右击项目并选择Publish. 点击Publish打开Publish Web对话框. 假设你在新建项目的时候选中 ...
- elementary OS安装搜狗输入法
© 版权声明:本文为博主原创文章,转载请注明出处 1.添加搜狗输入法的软件源 sudo add-apt-repository ppa:fcitx-team/nightly 1.1 可能遇到的问题: s ...
- Laravel 5.4---后端数据分页和前端显示分页结果
后端数据(Eloquent 模型)分页 事先建立好Eloquent 模型和Controller 还有 前台的View.可以参考我之前的文章:Laravel建站03--建立前台文章列表和文章详情 在co ...
- CentOS6.5下Oracle11G-R2安装、卸载
CentOS6.5下Oracle11G-R2安装.卸载 资源下载地址(包含本人全部安装过程中,系统备份文件):http://download.csdn.net/detail/attagain/7700 ...
- sealed,new,virtual,abstract与override关键字的区别?
1. sealed——“断子绝孙” 密封类不能被继承.密封方法可以重写基类中的方法,但其本身不能在任何派生类中进一步重写.当应用于方法或属性时,sealed修饰符必须始终与override一起使用. ...
- Docker入门系列3:使用
入门 首先强烈建议玩一遍官方的入门教程,Interactive commandline tutorial,下面是答案: 查看版本:docker version 搜索Image:docker searc ...
- iOS判断为空或者只为空格
本文转载至 :http://www.cnblogs.com/superhappy/archive/2012/11/08/2761403.html 经常有需求 要判断不能为空,后台老是鄙视不做非空判断的 ...