TODO: Expand beyond naming and formatting
#pragma once or header guards..cpp/.mm and .c/.m should have extension .h.cpp/.mm only should have extension .hpp*.c, *.cpp, *.m, *.mm). Use fully qualified names for definitions.extern "C" blocks inside implementation files.namespace kotlinnamespace kotlin in a nested namespace [module_name].h/.hpp into a nested namespace internal (e.g. implementation details of module mm go into namespace kotlin { namespace mm { namespace internal { ... } } }).cpp/.mm into a global anonymous namespaceextern "C" declarations emulate namespaces with Kotlin_[module_name]_ prefixes.kotlin::MoveOnlykotlin::Pinnedstd_support::* containers and smart pointers instead of std::* ones. The former ones default to runtime-specific allocator.new (std_support::kalloc) T(...) (defined in std_support/New.hpp instead of new T(...) and std_support::kdelete(ptr) instead of delete ptr. The former ones use runtime-specific allocator.PascalCasecamelCasecamelCasekPascalCase (with prefix k)camelCasePascalCasecamelCase. Private member fields should add _ suffix: camelCase_camelCaseSCREAMING_SNAKE_CASEsnake_caseenum and enum class members should use kPascalCaseIf API is designed to mimic C++ stdlib (e.g. stubbing <atomic> for platforms that do not support it), its allowed to follow stdlib naming conventions.
For automated formatting you can use config for CLion or clang-format (see config at the repo‘s root). Note, that CLion uses clang-format by default; this can be turned off if you prefer to use rules from CLionFormat.xml. Since 1.8.20 there’s also a :kotlin-native:clangFormat task that will effectively run git-clang-format -f $(git merge-base origin/master HEAD) -- kotlin-native/. The task accepts optional arguments --parent to specify base branch other than origin/master, and --interactive to run the tool with -p flag and interactively accept or reject formatted patches.
Formatting rules are designed to closely mirror Kotlin rules.
* and & should be placed on a type instead of a variable* at all.template and <