Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2015-03-17 13:48:47 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:40:06 +0300
commit85ddeff5f69f2f134f4db442cba3651df7084fd5 (patch)
tree5397804b327478d4f3dd8780d9b311633de05443 /docs
parente6502df585782a0ca9c1a4d749f3c3dc5ffd0c0a (diff)
Updated C++ coding standard
Diffstat (limited to 'docs')
-rw-r--r--docs/cpp_coding_standard.txt26
1 files changed, 16 insertions, 10 deletions
diff --git a/docs/cpp_coding_standard.txt b/docs/cpp_coding_standard.txt
index 0ce079b691..fa7bf65a71 100644
--- a/docs/cpp_coding_standard.txt
+++ b/docs/cpp_coding_standard.txt
@@ -2,16 +2,15 @@ We write code without warnings!
In general, Google's coding standard http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml is used and we strongly encourage to read it.
-Below are our specific exceptions to the Google's coding standard:
+Below are our specific (but not all!) exceptions to the Google's coding standard:
- We use .cpp and .hpp files, not .cc and .h (.c and .h are used for C code), in UTF-8 encoding
- File names are lowercase with underscores, like file_reader.cpp
-- We use #pragma once instead of the #define Guard
+- We use #pragma once instead of the #define Guard in header files.
- We don't include system, std and boost headers directly, use #include "../std/<wrapper.hpp>"
- We ARE using C++ exceptions
-- We don't support C++11 yet
-- We don't use boost libraries which require linking
-
+- We are using all features of C++11 (the only known exception is thread_local which is not fully supported on all platforms)
+- We don't use boost libraries which require linking (and prefer C++11 types over their boost counterparts)
Naming and formatting
@@ -26,7 +25,7 @@ Naming and formatting
- Space between binary operators, but can skip according to operators priority: x = y*y + z*z;
- Space after double dash
-// *********** Formatting Example ***********
+// *********** Formatting Example/Guide/Reference ***********
#include "../std/math.hpp"
typedef double TMyTypeStartsWithCapitalTLetter;
@@ -63,7 +62,8 @@ void CamelCaseFunctionName(int lowerCamelCaseVar)
namespace lower_case
{
-void SomeFoo(int a, int b)
+template <class TTemplateTypeStartsWithCapitalTLetter>
+void SomeFoo(int a, int b, TTemplateTypeStartsWithCapitalTLetter /* we avoid compilation warnings */)
{
for (int i = 0; i < a; ++i)
{
@@ -75,6 +75,8 @@ void SomeFoo(int a, int b)
{
Bar(i);
Bar(b);
+ // Commented out call
+ //Bar(c);
}
}
}
@@ -162,12 +164,16 @@ v = w * (x + z);
Tips and Hints
+- If you see outdated code which can be improved - DO IT NOW (but in the separate pull request)! Make this awesome world even more better!
+- Your code should work at least on [mac|win|linux|android][x86|x86_64], [ios|android][armv7|arm64] architectures
+- Your code should compile well with gcc 4.8+ and clang 3.5+
+- Try to avoid using any new 3party library if it is not fully tested and supported on all our platforms
- Cover your code with unit tests! See examples for existing libraries
- Check Base and Coding libraries for most of the basic functions
- Ask your team if you have any questions
-- Use dev@ mailing list to ask all developers and bugs@ mailing list to post bugs
+- Use dev@maps.me mailing list to ask all developers and bugs@maps.me mailing list to post bugs
- Release builds contain debugging information (for profiling), production builds are not
-- If you don't have enough time to make it right, leave a // @TODO need to fix it comment
+- If you don't have enough time to make it right, leave a '// TODO(DeveloperName): need to fix it' comment
- Some useful macroses:
-- #ifdef DEBUG | RELEASE | OMIM_PRODUCTION
-- #ifdef OMIM_OS_ANDROID | OMIM_OS_IPHONE | OMIM_OS_MAC (and some other useful OS-related macroses, see std/target_os.hpp)
@@ -180,7 +186,7 @@ Tips and Hints
LERROR - the same as LWARNING, but crashes in DEBUG and works in RELEASE
LCRITICAL - the same as LERROR and ALWAYS crashes
-- Need scope guard? Check MY_SCOPE_GUARD(name, func)
--- Calculate array size with ARRAY_SIZE(arrayVariable)
+-- Use std::array::size() to calculate plain C-array's size
-- Declare your own exceptions with DECLARE_EXCEPTION(name, baseException), where baseException is usually RootException
-- Throw exceptions with MYTHROW(exceptionName, (message))
-- A lot of useful string conversion utils are in base/string_utils.hpp