vios-cpp-standards · git:20260603.14e198c · 2026-06-03 · sha256 62dd6dcd30a184e1
vios-cpp-standards git:20260603.14e198cA
Immutable. This exact content is served forever at /api/v1/blob/62dd6dcd30a184e1.
--- description: C++17 coding standards, quality rules, and naming conventions for VIOS globs: "**/*.cpp,**/*.h,**/*.hpp" alwaysApply: false --- # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Language & Standard - **C++17** -- actively prefer modern features over legacy patterns: - `std::optional` / `std::variant` over raw pointers or sentinel values - RAII and smart pointers (`std::unique_ptr`, `std::shared_ptr`) -- avoid raw `new`/`delete` - `std::string_view` for read-only strings; range-based for loops; `auto`; `[[nodiscard]]` - Structured bindings, `if constexpr`, `std::chrono`, `std::filesystem` where applicable - All source files must carry the NVIDIA SPDX copyright header # Quality Rules - **No raw owning pointers** -- use `std::unique_ptr`, `std::shared_ptr`, or RAII wrappers - **No undefined behavior** -- avoid signed integer overflow, out-of-bounds access, dangling references, uninitialized variables - **Const correctness** -- apply `const` to parameters, member functions, and variables wherever appropriate - **Include guards** -- every header must have `#pragma once` (or traditional include guards) - **Warnings as errors** -- code must compile cleanly under `-Wall -Wextra -Werror` - **Never silently swallow errors** -- every error path must log or propagate; use `[[nodiscard]]` on functions whose return value must be checked - **Resource management** -- every acquisition must have a corresponding release on all code paths, including error paths # Naming Conventions - Classes: `PascalCase` -- Methods: `camelCase` -- Members: `m_camelCase` -- Constants: `UPPER_SNAKE_CASE` - Files match the primary class name (e.g., `WebsocketClient.cpp`)