Skip to content

Investigate C++17 dependencies that would break C++14 compatibility #171

@vtz

Description

@vtz

Summary

Investigate all C++17-specific features used in opensomeip's core library (src/ and include/) to determine which would prevent compilation under a C++14 toolchain. The goal is to produce a clear inventory and, where feasible, identify drop-in C++14 alternatives. The output of this investigation is one or more follow-up tickets with concrete changes — this ticket itself involves no code changes.

Motivation

Embedded BSW frameworks such as Eclipse OpenBSW standardize on C++14. Integrating opensomeip into such a codebase currently requires the entire project to raise its language standard to C++17, which may conflict with existing code, toolchain constraints, or coding guidelines. Understanding and potentially reducing our C++17 surface would make opensomeip accessible to a broader embedded audience.

Scope

Audit src/ and include/ only (not tests/, examples/, or zephyr/). Platform backends under include/platform/ are in scope since they ship with the library.

Known C++17 Features in Use (starting point)

Based on an initial scan, the following C++17 features are used in the core library:

std::optional

File Usage
include/someip/message.h Lines 149, 169
include/serialization/serializer.h Lines 92, 227–234
include/e2e/e2e_protection.h Line 73
src/serialization/serializer.cpp Lines 436, 447, 458, 478, 486, 494, 502, 512
src/e2e/e2e_protection.cpp Line 86
src/e2e/e2e_profiles/standard_profile.cpp Line 135

if constexpr

File Usage
include/serialization/serializer.h Lines 246–268, 285–307

Structured bindings (auto [a, b] = ...)

File Usage
src/transport/tcp_transport.cpp Line 90

[[nodiscard]]

File Usage
include/transport/transport.h Lines 78, 91, 97, 121, 127
include/transport/tcp_transport.h Lines 101, 109
include/transport/udp_transport.h Line 72

[[maybe_unused]]

File Usage
src/sd/sd_server.cpp Line 482
src/someip/message.cpp Lines 300, 356, 369

std::apply

File Usage
include/platform/zephyr/thread_impl.h Line 92
include/platform/threadx/thread_impl.h Line 141
include/platform/freertos/thread_impl.h Line 155

Features not used (confirmed absent)

std::string_view, std::variant, std::any, std::shared_mutex, std::filesystem, std::clamp, std::invoke, fold expressions, CTAD, nested namespace declarations (namespace a::b).

Investigation Tasks

  • For each C++17 feature above, assess whether a C++14-compatible alternative exists:
    • std::optional → custom Optional<T> wrapper, pointer + bool, or ETL etl::optional?
    • if constexpr → SFINAE / std::enable_if / tag dispatch?
    • Structured bindings → explicit member access?
    • [[nodiscard]] / [[maybe_unused]] → compiler-specific __attribute__ or remove?
    • std::apply → manual tuple unpacking with index sequence?
  • Evaluate whether a compile-time switch (e.g. #if __cplusplus >= 201703L) is viable vs. a full migration to C++14-only constructs
  • Assess impact on code readability and maintainability for each replacement
  • Identify any implicit C++17 dependencies (e.g. guaranteed copy elision, relaxed enum init, std::shared_ptr for arrays) that may not show up in a text search
  • Check if any third-party headers pulled via FetchContent require C++17
  • Document findings and create follow-up ticket(s) with the specific changes needed

Acceptance Criteria

  • Complete inventory of C++17 features with file locations, and assessment of C++14 alternatives
  • Follow-up ticket(s) created with concrete, actionable tasks
  • Decision documented: full C++14 compatibility vs. dual-standard support vs. "not feasible"

Related

  • OpenBSW integration planning (see related tickets)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions