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 kotlin
namespace 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 namespace
extern "C"
declarations emulate namespaces with Kotlin_[module_name]_
prefixes.kotlin::MoveOnly
kotlin::Pinned
std_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.PascalCase
camelCase
camelCase
kPascalCase
(with prefix k
)camelCase
PascalCase
camelCase
. Private member fields should add _
suffix: camelCase_
camelCase
SCREAMING_SNAKE_CASE
snake_case
enum
and enum class
members should use kPascalCase
If 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
.
Formatting rules are designed to closely mirror Kotlin rules.
*
and &
should be placed on a type instead of a variable*
at all.template
and <