objsim_cppguide.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type="text/xsl" href="styleguide.xsl"?>
  3. <GUIDE title="Objsim C++ Style Guide">
  4. <p align="right">
  5. Revision 0.1
  6. </p>
  7. <address>
  8. Frank Michler
  9. </address>
  10. <OVERVIEW>
  11. <CATEGORY title="Important Note">
  12. <STYLEPOINT title="Displaying Hidden Details in this Guide">
  13. <SUMMARY>
  14. This style guide contains many details that are initially
  15. hidden from view. They are marked by the triangle icon, which you
  16. see here on your left. Click it now.
  17. You should see "Hooray" appear below.
  18. </SUMMARY>
  19. <BODY>
  20. <p>
  21. Hooray! Now you know you can expand points to get more
  22. details. Alternatively, there's an "expand all" at the
  23. top of this document.
  24. </p>
  25. </BODY>
  26. </STYLEPOINT>
  27. </CATEGORY>
  28. <CATEGORY title="Background">
  29. <p>
  30. The objsim library is written in C++.
  31. This style guide is adapted from the "Google C++ Style Guide".
  32. </p>
  33. <p>
  34. The goal of this guide is to manage this complexity by describing
  35. in detail the dos and don'ts of writing C++
  36. code. These rules exist to
  37. keep
  38. the
  39. code base manageable while still allowing coders to use C++ language
  40. features productively.
  41. </p>
  42. <p>
  43. <em>Style</em>, also known as readability, is what we call the
  44. conventions that govern our C++ code. The term Style is a bit of a
  45. misnomer, since these conventions cover far more than just source
  46. file formatting.
  47. </p>
  48. <p>
  49. One way in which we keep the code base manageable is by enforcing
  50. <em>consistency</em>.
  51. It is very important that any
  52. programmer
  53. be able to look at another's code and quickly understand it.
  54. Maintaining a uniform style and following conventions means that we can
  55. more easily use "pattern-matching" to infer what various symbols are
  56. and what invariants are true about them. Creating common, required
  57. idioms and patterns makes code much easier to understand. In some
  58. cases there might be good arguments for changing certain style
  59. rules, but we nonetheless keep things as they are in order to
  60. preserve consistency.
  61. </p>
  62. <p>
  63. Another issue this guide addresses is that of C++ feature bloat.
  64. C++ is a huge language with many advanced features. In some cases
  65. we constrain, or even ban, use of certain features. We do this to
  66. keep code simple and to avoid the various common errors and
  67. problems that these features can cause. This guide lists these
  68. features and explains why their use is restricted.
  69. </p>
  70. <p>
  71. Note that this guide is not a C++ tutorial: we assume that the
  72. reader is familiar with the language.
  73. </p>
  74. </CATEGORY>
  75. </OVERVIEW>
  76. <CATEGORY title="Header Files">
  77. <p>
  78. In general, every <code>.cpp</code> file should have an associated
  79. <code>.hpp</code> file.
  80. </p>
  81. <p>
  82. Correct use of header files can make a huge difference to the
  83. readability, size and performance of your code.
  84. </p>
  85. <p>
  86. The following rules will guide you through the various pitfalls of
  87. using header files.
  88. </p>
  89. <STYLEPOINT title="The #define Guard">
  90. <SUMMARY>
  91. All header files should have <code>#define</code> guards to
  92. prevent multiple inclusion. The format of the symbol name
  93. should be
  94. <code><i>&lt;PROJECT&gt;</i>_<i>&lt;PATH&gt;</i>_<i>&lt;FILE&gt;</i>_HPP_</code>.
  95. </SUMMARY>
  96. <BODY>
  97. <p>
  98. To guarantee uniqueness, they should be based on the full path
  99. in a project's source tree. For example, the file
  100. <code>foo/src/bar/baz.hpp</code> in project <code>foo</code> should
  101. have the following guard:
  102. </p>
  103. <CODE_SNIPPET>
  104. #ifndef FOO_BAR_BAZ_H_
  105. #define FOO_BAR_BAZ_H_
  106. ...
  107. #endif // FOO_BAR_BAZ_H_
  108. </CODE_SNIPPET>
  109. </BODY>
  110. </STYLEPOINT>
  111. <STYLEPOINT title="Header File Dependencies">
  112. <SUMMARY>
  113. Don't use an <code>#include</code> when a forward declaration
  114. would suffice.
  115. </SUMMARY>
  116. <BODY>
  117. <p>
  118. When you include a header file you introduce a dependency that
  119. will cause your code to be recompiled whenever the header file
  120. changes. If your header file includes other header files, any
  121. change to those files will cause any code that includes your
  122. header to be recompiled. Therefore, we prefer to minimize
  123. includes, particularly includes of header files in other
  124. header files.
  125. </p>
  126. <p>
  127. You can significantly minimize the number of header files you
  128. need to include in your own header files by using forward
  129. declarations. For example, if your header file uses the
  130. <code>File</code> class in ways that do not require access to
  131. the declaration of the <code>File</code> class, your header
  132. file can just forward declare <code>class File;</code> instead
  133. of having to <code>#include "file/base/file.hpp"</code>.
  134. </p>
  135. <p>
  136. How can we use a class <code>Foo</code> in a header file
  137. without access to its definition?
  138. </p>
  139. <ul>
  140. <li> We can declare data members of type <code>Foo*</code> or
  141. <code>Foo&amp;</code>.
  142. </li>
  143. <li> We can declare (but not define) functions with arguments,
  144. and/or return values, of type <code>Foo</code>.
  145. </li>
  146. <li> We can declare static data members of type
  147. <code>Foo</code>. This is because static data members
  148. are defined outside the class definition.
  149. </li>
  150. </ul>
  151. <p>
  152. On the other hand, you must include the header file for
  153. <code>Foo</code> if your class subclasses <code>Foo</code> or
  154. has a data member of type <code>Foo</code>.
  155. </p>
  156. <p>
  157. Sometimes it makes sense to have pointer (or better,
  158. <code>scoped_ptr</code>)
  159. members instead of object members. However, this complicates code
  160. readability and imposes a performance penalty, so avoid doing
  161. this transformation if the only purpose is to minimize includes
  162. in header files.
  163. </p>
  164. <p>
  165. Of course, <code>.cpp</code> files typically do require the
  166. definitions of the classes they use, and usually have to
  167. include several header files.
  168. </p>
  169. </BODY>
  170. </STYLEPOINT>
  171. <STYLEPOINT title="Inline Functions">
  172. <SUMMARY>
  173. Define functions inline only when they are small, say, 10 lines
  174. or less.
  175. </SUMMARY>
  176. <BODY>
  177. <DEFINITION>
  178. You can declare functions in a way that allows the compiler to
  179. expand them inline rather than calling them through the usual
  180. function call mechanism.
  181. </DEFINITION>
  182. <PROS>
  183. Inlining a function can generate more efficient object code,
  184. as long as the inlined function is small. Feel free to inline
  185. accessors and mutators, and other short, performance-critical
  186. functions.
  187. </PROS>
  188. <CONS>
  189. Overuse of inlining can actually make programs slower.
  190. Depending on a function's size, inlining it can cause the code
  191. size to increase or decrease. Inlining a very small accessor
  192. function will usually decrease code size while inlining a very
  193. large function can dramatically increase code size. On modern
  194. processors smaller code usually runs faster due to better use
  195. of the instruction cache.
  196. </CONS>
  197. <DECISION>
  198. <p>
  199. A decent rule of thumb is to not inline a function if it is
  200. more than 10 lines long. Beware of destructors, which are
  201. often longer than they appear because of implicit member-
  202. and base-destructor calls!
  203. </p>
  204. <p>
  205. Another useful rule of thumb: it's typically not cost
  206. effective to inline functions with loops or switch
  207. statements (unless, in the common case, the loop or switch
  208. statement is never executed).
  209. </p>
  210. <p>
  211. It is important to know that functions are not always
  212. inlined even if they are declared as such; for example,
  213. virtual and recursive functions are not normally inlined.
  214. Usually recursive functions should not be inline. The main
  215. reason for making a virtual function inline is to place its
  216. definition in the class, either for convenience or to
  217. document its behavior, e.g., for accessors and mutators.
  218. </p>
  219. </DECISION>
  220. </BODY>
  221. </STYLEPOINT>
  222. <STYLEPOINT title="The -inl.hpp Files">
  223. <SUMMARY>
  224. You may use file names with a <code>-inl.hpp</code> suffix to define
  225. complex inline functions when needed.
  226. </SUMMARY>
  227. <BODY>
  228. <p>
  229. The definition of an inline function needs to be in a header
  230. file, so that the compiler has the definition available for
  231. inlining at the call sites. However, implementation code
  232. properly belongs in <code>.cpp</code> files, and we do not like
  233. to have much actual code in <code>.hpp</code> files unless there
  234. is a readability or performance advantage.
  235. </p>
  236. <p>
  237. If an inline function definition is short, with very little,
  238. if any, logic in it, you should put the code in your
  239. <code>.hpp</code> file. For example, accessors and mutators
  240. should certainly be inside a class definition. More complex
  241. inline functions may also be put in a <code>.hpp</code> file for
  242. the convenience of the implementer and callers, though if this
  243. makes the <code>.hpp</code> file too unwieldy you can instead
  244. put that code in a separate <code>-inl.hpp</code> file.
  245. This separates the implementation from the class definition,
  246. while still allowing the implementation to be included where
  247. necessary.
  248. </p>
  249. <p>
  250. Another use of <code>-inl.hpp</code> files is for definitions of
  251. function templates. This can be used to keep your template
  252. definitions easy to read.
  253. </p>
  254. <p>
  255. Do not forget that a <code>-inl.hpp</code> file requires a
  256. <a href="#The__define_Guard"><code>#define</code> guard</a> just
  257. like any other header file.
  258. </p>
  259. </BODY>
  260. </STYLEPOINT>
  261. <STYLEPOINT title="Function Parameter Ordering">
  262. <SUMMARY>
  263. When defining a function, parameter order is: inputs,
  264. then outputs.
  265. </SUMMARY>
  266. <BODY>
  267. <p>
  268. Parameters to C/C++ functions are either input to the
  269. function, output from the function, or both. Input parameters
  270. are usually values or <code>const</code> references, while output
  271. and input/output parameters will be non-<code>const</code>
  272. pointers. When ordering function parameters, put all input-only
  273. parameters before any output parameters. In particular, do not add
  274. new parameters to the end of the function just because they are
  275. new; place new input-only parameters before the output
  276. parameters.
  277. </p>
  278. <p>
  279. This is not a hard-and-fast rule. Parameters that are both
  280. input and output (often classes/structs) muddy the waters,
  281. and, as always, consistency with related functions may require
  282. you to bend the rule.
  283. </p>
  284. </BODY>
  285. </STYLEPOINT>
  286. </CATEGORY>
  287. <CATEGORY title="Naming">
  288. <p>
  289. The most important consistency rules are those that govern
  290. naming. The style of a name immediately informs us what sort of
  291. thing the named entity is: a type, a variable, a function, a
  292. constant, a macro, etc., without requiring us to search for the
  293. declaration of that entity. The pattern-matching engine in our
  294. brains relies a great deal on these naming rules.
  295. </p>
  296. <p>
  297. Naming rules are pretty arbitrary, but
  298. we feel that consistency is more important than individual preferences
  299. in this area, so regardless of whether you find them sensible or not,
  300. the rules are the rules.
  301. </p>
  302. <STYLEPOINT title="General Naming Rules">
  303. <SUMMARY>
  304. Function names, variable names, and filenames should be
  305. descriptive; eschew abbreviation. Types and variables should be
  306. nouns, while functions should be "command" verbs.
  307. </SUMMARY>
  308. <BODY>
  309. <SUBSECTION title="How to Name">
  310. <p>
  311. Give as descriptive a name as possible, within reason. Do
  312. not worry about saving horizontal space as it is far more
  313. important to make your code immediately understandable by a
  314. new reader. Examples of well-chosen names:
  315. </p>
  316. <CODE_SNIPPET>
  317. int num_errors; // Good.
  318. int num_completed_connections; // Good.
  319. </CODE_SNIPPET>
  320. <p>
  321. Poorly-chosen names use ambiguous abbreviations or arbitrary
  322. characters that do not convey meaning:
  323. </p>
  324. <BAD_CODE_SNIPPET>
  325. int n; // Bad - meaningless.
  326. int nerr; // Bad - ambiguous abbreviation.
  327. int n_comp_conns; // Bad - ambiguous abbreviation.
  328. </BAD_CODE_SNIPPET>
  329. <p>
  330. Type and variable names should typically be nouns: e.g.,
  331. <code>FileOpener</code>,
  332. <code>num_errors</code>.
  333. </p>
  334. <p>
  335. Function names should typically be imperative (that is they
  336. should be commands): e.g., <code>OpenFile()</code>,
  337. <code>set_num_errors()</code>. There is an exception for
  338. accessors, which, described more completely in <a HREF="#Function_Names">Function Names</a>, should be named
  339. the same as the variable they access.
  340. </p>
  341. </SUBSECTION>
  342. <SUBSECTION title="Abbreviations">
  343. <p>
  344. Do not use abbreviations unless they are extremely well
  345. known outside your project. For example:
  346. </p>
  347. <CODE_SNIPPET>
  348. // Good
  349. // These show proper names with no abbreviations.
  350. int num_dns_connections; // Most people know what "DNS" stands for.
  351. int price_count_reader; // OK, price count. Makes sense.
  352. </CODE_SNIPPET>
  353. <BAD_CODE_SNIPPET>
  354. // Bad!
  355. // Abbreviations can be confusing or ambiguous outside a small group.
  356. int wgc_connections; // Only your group knows what this stands for.
  357. int pc_reader; // Lots of things can be abbreviated "pc".
  358. </BAD_CODE_SNIPPET>
  359. <p>
  360. Never abbreviate by leaving out letters:
  361. </p>
  362. <CODE_SNIPPET>
  363. int error_count; // Good.
  364. </CODE_SNIPPET>
  365. <BAD_CODE_SNIPPET>
  366. int error_cnt; // Bad.
  367. </BAD_CODE_SNIPPET>
  368. </SUBSECTION>
  369. </BODY>
  370. </STYLEPOINT>
  371. <STYLEPOINT title="File Names">
  372. <SUMMARY>
  373. Filenames should be all lowercase and can include underscores
  374. (<code>_</code>) or dashes (<code>-</code>). Follow the
  375. convention that your
  376. project
  377. uses. If there is no consistent local pattern to follow, prefer "_".
  378. </SUMMARY>
  379. <BODY>
  380. <p>
  381. Examples of acceptable file names:
  382. </p>
  383. <p>
  384. <code>
  385. my_useful_class.cpp<br/>
  386. my-useful-class.cpp<br/>
  387. myusefulclass.cpp<br/>
  388. </code>
  389. </p>
  390. <p>
  391. C++ files should end in <code>.cpp</code> and header files
  392. should end in <code>.hpp</code>.
  393. </p>
  394. <p>
  395. Do not use filenames that already exist
  396. in <code>/usr/include</code>, such as <code>db.h</code>.
  397. </p>
  398. <p>
  399. In general, make your filenames very specific. For example,
  400. use <code>http_server_logs.h</code> rather
  401. than <code>logs.h</code>. A very common case is to have a
  402. pair of files called, e.g., <code>foo_bar.hpp</code>
  403. and <code>foo_bar.cpp</code>, defining a class
  404. called <code>FooBar</code>.
  405. </p>
  406. <p>
  407. Inline functions must be in a <code>.hpp</code> file. If your
  408. inline functions are very short, they should go directly into your
  409. <code>.hpp</code> file. However, if your inline functions
  410. include a lot of code, they may go into a third file that
  411. ends in <code>-inl.hpp</code>. In a class with a lot of inline
  412. code, your class could have three files:
  413. </p>
  414. <CODE_SNIPPET>
  415. url_table.hpp // The class declaration.
  416. url_table.cpp // The class definition.
  417. url_table-inl.hpp // Inline functions that include lots of code.
  418. </CODE_SNIPPET>
  419. <p>
  420. See also the section <a href="#The_-inl.hpp_Files">-inl.hpp Files</a>
  421. </p>
  422. </BODY>
  423. </STYLEPOINT>
  424. <STYLEPOINT title="Type Names">
  425. <SUMMARY>
  426. Type names start with a capital letter and have a capital
  427. letter for each new word, with no underscores:
  428. <code>MyExcitingClass</code>, <code>MyExcitingEnum</code>.
  429. </SUMMARY>
  430. <BODY>
  431. <p>
  432. The names of all types &#8212; classes, structs, typedefs, and enums
  433. &#8212; have the same naming convention. Type names should start
  434. with a capital letter and have a capital letter for each new
  435. word. No underscores. For example:
  436. </p>
  437. <CODE_SNIPPET>
  438. // classes and structs
  439. class UrlTable { ...
  440. class UrlTableTester { ...
  441. struct UrlTableProperties { ...
  442. // typedefs
  443. typedef hash_map&lt;UrlTableProperties *, string&gt; PropertiesMap;
  444. // enums
  445. enum UrlTableErrors { ...
  446. </CODE_SNIPPET>
  447. </BODY>
  448. </STYLEPOINT>
  449. <STYLEPOINT title="Variable Names">
  450. <SUMMARY>
  451. Variable names should start with a capital letter and have a
  452. capital letter for each new word. No underscores, except for cases where underscores
  453. drastically increase readability. For instance: <code>mNMDA_AMPA_Ratio</code>. Class member variables start with leading letter "m". For
  454. instance: <code>ExcitingLocalVariable</code>,
  455. <code>mExcitingMemberVariable</code>.
  456. </SUMMARY>
  457. <BODY>
  458. <SUBSECTION title="Common Variable names">
  459. <p>
  460. For example:
  461. </p>
  462. <CODE_SNIPPET>
  463. string TableName; // OK - uses mixed case.
  464. </CODE_SNIPPET>
  465. <BAD_CODE_SNIPPET>
  466. string tablename; // Bad - all lowercase.
  467. </BAD_CODE_SNIPPET>
  468. </SUBSECTION>
  469. <SUBSECTION title="Class Data Members">
  470. <p>
  471. Data members (also called instance variables or member
  472. variables) are lowercase with optional underscores like
  473. regular variable names, but always start with a leading letter "m".
  474. </p>
  475. <CODE_SNIPPET>
  476. string mTableName; // OK - underscore at end.
  477. </CODE_SNIPPET>
  478. </SUBSECTION>
  479. <SUBSECTION title="Struct Variables">
  480. <p>
  481. Data members in structs should be named like regular
  482. variables without the leading "m" that data members
  483. in classes have.
  484. </p>
  485. <CODE_SNIPPET>
  486. struct UrlTableProperties {
  487. string Name;
  488. int NumEntries;
  489. }
  490. </CODE_SNIPPET>
  491. <p>
  492. See <a HREF="#Structs_vs._Classes">Structs vs. Classes</a> for a
  493. discussion of when to use a struct versus a class.
  494. </p>
  495. </SUBSECTION>
  496. <SUBSECTION title="Global Variables">
  497. <p>
  498. There are no special requirements for global variables,
  499. which should be rare in any case, but if you use one,
  500. consider prefixing it with <code>g_</code> or some other
  501. marker to easily distinguish it from local variables.
  502. </p>
  503. </SUBSECTION>
  504. </BODY>
  505. </STYLEPOINT>
  506. <STYLEPOINT title="Constant Names">
  507. <SUMMARY>
  508. Use a <code>k</code> followed by mixed case:
  509. <code>kDaysInAWeek</code>.
  510. </SUMMARY>
  511. <BODY>
  512. <p>
  513. All compile-time constants, whether they are declared locally,
  514. globally, or as part of a class, follow a slightly different
  515. naming convention from other variables. Use a <code>k</code>
  516. followed by words with uppercase first letters:
  517. </p>
  518. <CODE_SNIPPET>
  519. const int kDaysInAWeek = 7;
  520. </CODE_SNIPPET>
  521. </BODY>
  522. </STYLEPOINT>
  523. <STYLEPOINT title="Function Names">
  524. <SUMMARY>
  525. Regular functions have mixed case and start with lower case letter; accessors and mutators match
  526. the name of the variable: <code>excitingFunction()</code>,
  527. <code>excitingMethod()</code>,
  528. <code>ExcitingMemberVariable()</code>,
  529. <code>setExcitingMemberVariable()</code>.
  530. </SUMMARY>
  531. <BODY>
  532. <SUBSECTION title="Regular Functions">
  533. <p>
  534. Functions should start with a lower case and have a
  535. capital letter for each new word. No underscores:
  536. </p>
  537. <CODE_SNIPPET>
  538. addTableEntry()
  539. deleteUrl()
  540. </CODE_SNIPPET>
  541. </SUBSECTION>
  542. <SUBSECTION title="Accessors and Mutators">
  543. <p>
  544. Accessors and mutators (get and set functions) should match
  545. the name of the variable they are getting and setting. This
  546. shows an excerpt of a class whose instance variable is
  547. <code>mNumEntries</code>.
  548. </p>
  549. <CODE_SNIPPET>
  550. class MyClass {
  551. public:
  552. ...
  553. int NumEntries() const { return mNumEntries; }
  554. void setNumEntries(int Num_Entries) { mNumEntries = NumEntries; }
  555. private:
  556. int NumEntries;
  557. };
  558. </CODE_SNIPPET>
  559. <p>
  560. You may also use lowercase letters for other very short
  561. inlined functions. For example if a function were so cheap
  562. you would not cache the value if you were calling it in a
  563. loop, then lowercase naming would be acceptable.
  564. </p>
  565. </SUBSECTION>
  566. </BODY>
  567. </STYLEPOINT>
  568. <STYLEPOINT title="Namespace Names">
  569. <SUMMARY>
  570. Namespace names are all lower-case, and based on project names and
  571. possibly their directory structure:
  572. <code>google_awesome_project</code>.
  573. </SUMMARY>
  574. <BODY>
  575. <p>
  576. See <a HREF="#Namespaces">Namespaces</a> for a discussion of
  577. namespaces and how to name them.
  578. </p>
  579. </BODY>
  580. </STYLEPOINT>
  581. <STYLEPOINT title="Enumerator Names">
  582. <SUMMARY>
  583. Enumerators should be named like
  584. <A HREF="#Constant_Names">constants</A> <code>kEnumName</code>.
  585. </SUMMARY>
  586. <BODY>
  587. <p>
  588. Preferably, the individual enumerators should be named like
  589. <A HREF="#Constant_Names">constants</A>. The enumeration name,
  590. <code>UrlTableErrors</code> (and
  591. <code>AlternateUrlTableErrors</code>), is a type, and
  592. therefore mixed case.
  593. </p>
  594. <CODE_SNIPPET>
  595. enum UrlTableErrors {
  596. kOK = 0,
  597. kErrorOutOfMemory,
  598. kErrorMalformedInput,
  599. };
  600. </CODE_SNIPPET>
  601. </BODY>
  602. </STYLEPOINT>
  603. <STYLEPOINT title="Macro Names">
  604. <SUMMARY>
  605. You're not really going to <A HREF="#Preprocessor_Macros">define
  606. a macro</A>, are you? If you do, they're like this:
  607. <code>MY_MACRO_THAT_SCARES_SMALL_CHILDREN</code>.
  608. </SUMMARY>
  609. <BODY>
  610. <p>
  611. Please see the <a href="#Preprocessor_Macros">description of
  612. macros</a>; in general macros should <em>not</em> be used.
  613. However, if they are absolutely needed, then they should be
  614. named like enum value names with all capitals and underscores.
  615. </p>
  616. <CODE_SNIPPET>
  617. #define ROUND(x) ...
  618. #define PI_ROUNDED 3.0
  619. </CODE_SNIPPET>
  620. </BODY>
  621. </STYLEPOINT>
  622. <STYLEPOINT title="Exceptions to Naming Rules">
  623. <SUMMARY>
  624. If you are naming something that is analogous to an existing C
  625. or C++ entity then you can follow the existing naming convention
  626. scheme.
  627. </SUMMARY>
  628. <BODY>
  629. <p>
  630. <dl>
  631. <dt> <code>bigopen()</code> </dt>
  632. <dd> function name, follows form of <code>open()</code> </dd>
  633. <dt> <code>uint</code> </dt>
  634. <dd> <code>typedef</code> </dd>
  635. <dt> <code>bigpos</code> </dt>
  636. <dd> <code>struct</code> or <code>class</code>, follows form of
  637. <code>pos</code> </dd>
  638. <dt> <code>sparse_hash_map</code> </dt>
  639. <dd> STL-like entity; follows STL naming conventions </dd>
  640. <dt> <code>LONGLONG_MAX</code> </dt>
  641. <dd> a constant, as in <code>INT_MAX</code> </dd>
  642. </dl>
  643. </p>
  644. </BODY>
  645. </STYLEPOINT>
  646. </CATEGORY>
  647. <HR/>
  648. <p align="right">
  649. Revision 0.1
  650. </p>
  651. <address>
  652. Frank Michler
  653. </address>
  654. </GUIDE>