diff --git a/kotlin-native/codestyle/cpp/README.md b/kotlin-native/codestyle/cpp/README.md index 0a078aa2a1b..8deda2e0f3b 100644 --- a/kotlin-native/codestyle/cpp/README.md +++ b/kotlin-native/codestyle/cpp/README.md @@ -4,9 +4,22 @@ ## Headers -* Headers should live in the same folder with it's implementation counterpart (if there's one) +* Headers should live in the same folder with it's implementation counterpart (if there's one) **TODO**: This does not work with multiple implementations of a single header. * Headers should use header guards +## Namespace usage + +* Do not use namespace blocks inside implementation files (`*.c`, `*.cpp`, `*.m`, `*.mm`). Use fully qualified names for definitions. +* Do not use `extern "C"` blocks inside implementation files. + +### Runtime-specific + +* Put main module inside `namespace kotlin` +* Put other modules under `namespace kotlin` in a nested `namespace [module_name]` +* Put implementation details inside `.h`/`.hpp` into a nested `namespace internal` (e.g. implementation details of module `mm` go into `namespace kotlin { namespace mm { namespace internal { ... } } }`) +* Put implementation details inside `.cpp`/`.mm` into a global anonymous `namespace` +* For `extern "C"` declarations emulate namespaces with `Kotlin_[module_name]_` prefixes. + ## Naming * Types should use `PascalCase`