diff --git a/.gitignore b/.gitignore index 9f803290db9..2b10443f14a 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ __pycache__/ # IDE files .vscode/* .theia/* +*.code-workspace # Container files **/.docker/* diff --git a/CppAPICodingStyle.md b/CppAPICodingStyle.md index 4543a013b76..ed0fd03e028 100644 --- a/CppAPICodingStyle.md +++ b/CppAPICodingStyle.md @@ -67,8 +67,8 @@ We define three API layers as illustrated below: │ Audience: Hardware vendors + core developers │ │ (NOT for users / external libs to depend on) │ │ Headers: "cudaq_internal//.h" (or cudaq_dev/...) │ -│ Namespace: cudaq::::... (module lowercase) │ -│ cudaq::::detail = NON-public │ +│ Namespace: cudaq_internal::::... (module lowercase) │ +│ cudaq_internal::::detail = private │ │ Naming: CamelCase (or consistent module convention) │ └────────────────────────────────────────────────────────────────────┘ ▲ @@ -78,8 +78,8 @@ We define three API layers as illustrated below: │ Level 3: Internal Private APIs │ ├────────────────────────────────────────────────────────────────────┤ │ Audience: Module implementers only │ -│ Headers: module-local (e.g., /src/, include-private/) │ -│ Namespace: typically in cudaq::::detail (recommended) │ +│ Headers: module local (e.g., /src/, include-private/) │ +│ Namespace: typically in cudaq_internal::::detail │ │ Naming: unconstrained; keep consistent within module │ └────────────────────────────────────────────────────────────────────┘ ``` @@ -167,9 +167,9 @@ shipped user headers as required by `nvq++` compilation. #### 3.2.4 Namespaces -- Declarations live under a module namespace nested in `cudaq`: +- Declarations live under a module namespace nested in `cudaq_internal`: - `namespace cudaq:: { ... }` where `` is lowercase - Examples: `cudaq::compiler`, `cudaq::cudaq_fmt` + Examples: `cudaq_internal::compiler`, `cudaq_internal::device_code` - Nested namespaces follow the same visibility convention: they are public except for the `detail` namespace. @@ -256,7 +256,7 @@ namespace cudaq { Internal module API: ```cpp -namespace cudaq::compiler { +namespace cudaq_internal::compiler { class PassPipeline; namespace detail { @@ -264,3 +264,12 @@ namespace cudaq::compiler { } } ``` + +## 5. Additional conventions + +This documented primarily aims at defining conventions on APIs and modules. +Of particular relevance are the following rules from the LLVM coding standard +that we shall strive to follow. + +- [Use Namespace Qualifiers to Define Previously Declared Symbols](https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-define-previously-declared-symbols) +- [Restrict Visibility](https://llvm.org/docs/CodingStandards.html#restrict-visibility)