| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
- <meta http-equiv="X-UA-Compatible" content="IE=9"/>
- <meta name="generator" content="Doxygen 1.8.6"/>
- <title>GRPC Core: GRPC C STYLE GUIDE</title>
- <link href="tabs.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript" src="dynsections.js"></script>
- <link href="search/search.css" rel="stylesheet" type="text/css"/>
- <script type="text/javascript" src="search/search.js"></script>
- <script type="text/javascript">
- $(document).ready(function() { searchBox.OnSelectItem(0); });
- </script>
- <link href="doxygen.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
- <div id="titlearea">
- <table cellspacing="0" cellpadding="0">
- <tbody>
- <tr style="height: 56px;">
- <td style="padding-left: 0.5em;">
- <div id="projectname">GRPC Core
-  <span id="projectnumber">4.0.0</span>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- end header part -->
- <!-- Generated by Doxygen 1.8.6 -->
- <script type="text/javascript">
- var searchBox = new SearchBox("searchBox", "search",false,'Search');
- </script>
- <div id="navrow1" class="tabs">
- <ul class="tablist">
- <li><a href="index.html"><span>Main Page</span></a></li>
- <li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
- <li><a href="modules.html"><span>Modules</span></a></li>
- <li><a href="annotated.html"><span>Data Structures</span></a></li>
- <li><a href="files.html"><span>Files</span></a></li>
- <li>
- <div id="MSearchBox" class="MSearchBoxInactive">
- <span class="left">
- <img id="MSearchSelect" src="search/mag_sel.png"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- alt=""/>
- <input type="text" id="MSearchField" value="Search" accesskey="S"
- onfocus="searchBox.OnSearchFieldFocus(true)"
- onblur="searchBox.OnSearchFieldFocus(false)"
- onkeyup="searchBox.OnSearchFieldChange(event)"/>
- </span><span class="right">
- <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
- </span>
- </div>
- </li>
- </ul>
- </div>
- <!-- window showing the filter options -->
- <div id="MSearchSelectWindow"
- onmouseover="return searchBox.OnSearchSelectShow()"
- onmouseout="return searchBox.OnSearchSelectHide()"
- onkeydown="return searchBox.OnSearchSelectKey(event)">
- <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Pages</a></div>
- <!-- iframe showing the search results (closed by default) -->
- <div id="MSearchResultsWindow">
- <iframe src="javascript:void(0)" frameborder="0"
- name="MSearchResults" id="MSearchResults">
- </iframe>
- </div>
- </div><!-- top -->
- <div class="header">
- <div class="headertitle">
- <div class="title">GRPC C STYLE GUIDE </div> </div>
- </div><!--header-->
- <div class="contents">
- <div class="textblock"><h2>Background </h2>
- <p>Here we document style rules for C usage in the gRPC Core library.</p>
- <h2>General </h2>
- <ul>
- <li>Layout rules are defined by clang-format, and all code should be passed through clang-format. A (docker-based) script to do so is included in <a href="../tools/distrib/clang_format_code.sh">tools/distrib/clang\_format\_code.sh</a>.</li>
- </ul>
- <h2>Header Files </h2>
- <ul>
- <li>Public header files (those in the include/grpc tree) should compile as pedantic C89.</li>
- <li>Public header files should be includable from C++ programs. That is, they should include the following: ```c #ifdef __cplusplus extern "C" { <h1>endif</h1>
- </li>
- </ul>
- <p>/* ... body of file ...</p>
- <p>#ifdef __cplusplus } </p>
- <h1>endif</h1>
- <p>```</p>
- <ul>
- <li>Header files should be self-contained and end in .h.</li>
- <li><p class="startli">All header files should have a #define guard to prevent multiple inclusion. To guarantee uniqueness they should be based on the file's path.</p>
- <p class="startli">For public headers: <code><a class="el" href="grpc_8h.html">include/grpc/grpc.h</a></code> → <code>GRPC_GRPC_H</code></p>
- <p class="startli">For private headers: <code>src/core/channel/channel_stack.h</code> → <code>GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H</code></p>
- </li>
- </ul>
- <h2>Variable Initialization </h2>
- <p>When declaring a (non-static) pointer variable, always initialize it to <code>NULL</code>. Even in the case of static pointer variables, it's recommended to explicitly initialize them to <code>NULL</code>.</p>
- <h2>C99 Features </h2>
- <ul>
- <li>Variable sized arrays are not allowed.</li>
- <li>Do not use the 'inline' keyword.</li>
- <li>Flexible array members are allowed (<a href="https://en.wikipedia.org/wiki/Flexible_array_member">https://en.wikipedia.org/wiki/Flexible_array_member</a>).</li>
- </ul>
- <h2>Comments </h2>
- <p>Within public header files, only <code>/*</code> comments are allowed.</p>
- <p>Within implementation files and private headers, either single line <code>//</code> or multi line <code>/*</code> comments are allowed. Only one comment style per file is allowed however (i.e. if single line comments are used anywhere within a file, ALL comments within that file must be single line comments).</p>
- <h2>Symbol Names </h2>
- <ul>
- <li>Non-static functions must be prefixed by <code>grpc_</code></li>
- <li>Static functions must <em>not</em> be prefixed by <code>grpc_</code></li>
- <li>Enumeration values and <code>#define</code> names must be uppercase. All other values must be lowercase.</li>
- <li>Multiple word identifiers use underscore as a delimiter, <em>never</em> camel case. E.g. <code>variable_name</code>.</li>
- </ul>
- <h2>Functions </h2>
- <ul>
- <li>The use of <a href="http://man7.org/linux/man-pages/man3/atexit.3.html">`atexit()`</a> is in forbidden in libgrpc. </li>
- </ul>
- </div></div><!-- contents -->
- <!-- start footer part -->
- <hr class="footer"/><address class="footer"><small>
- Generated on Wed Jun 21 2017 14:13:07 for GRPC Core by  <a href="http://www.doxygen.org/index.html">
- <img class="footer" src="doxygen.png" alt="doxygen"/>
- </a> 1.8.6
- </small></address>
- </body>
- </html>
|