Skip to content

Conversation

ockeydockey
Copy link
Contributor

When exceptions are disabled in IAR 8.x, the keyword noexcept in any form will cause a build error.

Adding back in the conditional support for the noexcept keyword based on the etl_profile settings.

#define ETL_LVALUE_REF_QUALIFIER &
#define ETL_NOEXCEPT noexcept
#define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__)
#if ETL_USING_EXCEPTIONS
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwellbelove, if you don't like using this flag, I can also recommend using the feature test macro in the C++ standard:

#if defined(__cpp_exceptions)

Copy link

coderabbitai bot commented Oct 2, 2025

Walkthrough

The change updates macro definitions for exception specifications in the ETL C++11 configuration. ETL_NOEXCEPT and ETL_NOEXCEPT_EXPR(...) are now conditionally defined based on ETL_USING_EXCEPTIONS. When exceptions are enabled, they expand to noexcept and noexcept(VA_ARGS) respectively; when disabled, they expand to empty. This replaces prior unconditional definitions of these macros.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarises the primary change of adding conditional noexcept support to address IAR build issues with disabled exceptions. It is concise, specific, and directly reflects the modifications made in the pull request.
Description Check ✅ Passed The description clearly explains the IAR build error caused by noexcept when exceptions are disabled and states that conditional support is being restored based on the etl_profile, directly matching the implemented change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9cf20d and efb8771.

📒 Files selected for processing (1)
  • include/etl/platform.h (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
include/etl/*.h

⚙️ CodeRabbit configuration file

include/etl/*.h: Review the C++ code in these directories. The code must not use
STL containers but must instead rely on Embedded Template Library
(ETL) for data structures and algorithms.

When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
Always be polite and professional in your responses.

Header files should start with the ETL's standard MIT comment block.

Header files should have include guards in the format '#ifndef ETL_>INCLUDED #define ETL_INCLUDED #endif'

Headers should be organized in the following order

  • The first header include should be '#include "platform.h"'
  • Headers from the ETL
  • Headers from the path 'private/**'
  • C++ standard library headers
  • C standard library headers

Pay extra attention to the following

  • Buffer overflows
  • Memory leaks
  • Undefined behavior

Check that the following conventions are used

  • Variable names should be in snake_case
  • Macro constants should be ALL_CAPS_WITH_UNDERSCORES
  • Macro constants should be prefixed with 'ETL_'
  • Function, class, and type names should be snake_case
  • enum members should be Caps_Snake_Case

Please keep your outputs short and to the point, unless otherwise asked

  • Keep your responses short, describe small issues in a few sentences
  • Don't output tips, analysis chains or anything else with a collapsible view
  • Don't output comment summaries or fix prompts for AIs
  • If the highlighted issue is complex, don't suggest a solution
  • Don't use emojis

Files:

  • include/etl/platform.h
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: GCC C++23 Linux - No STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: GCC C++20 Linux - No STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: GCC C++23 Linux - STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: Clang C++23 Linux - STL - Force C++03 (ubuntu-22.04)
  • GitHub Check: Clang C++14 Linux - STL (ubuntu-22.04)
  • GitHub Check: Clang C++17 Linux - No STL (ubuntu-22.04)
  • GitHub Check: Clang C++17 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++17 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++23 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++11 Linux - STL (ubuntu-22.04)
  • GitHub Check: Windows - No STL
  • GitHub Check: GCC C++20 Linux - STL (ubuntu-22.04)
  • GitHub Check: GCC C++20 Linux - No STL (ubuntu-22.04)
  • GitHub Check: GCC C++11 Linux - No STL (ubuntu-22.04)
  • GitHub Check: Clang C++14 Linux - No STL (ubuntu-22.04)
  • GitHub Check: GCC C++17 Linux - No STL (ubuntu-22.04)
  • GitHub Check: GCC C++14 Linux - STL (ubuntu-22.04)
  • GitHub Check: Windows - No STL - Force C++03
  • GitHub Check: Windows - STL
  • GitHub Check: Windows - STL - Force C++03

Comment on lines +334 to +340
#if ETL_USING_EXCEPTIONS
#define ETL_NOEXCEPT noexcept
#define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__)
#else
#define ETL_NOEXCEPT
#define ETL_NOEXCEPT_EXPR(...)
#endif
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Conditional noexcept correctly implements IAR workaround.

The conditional definition properly addresses IAR 8.x's rejection of the noexcept keyword when exceptions are disabled. The logic is sound: when ETL_USING_EXCEPTIONS is true, the macros expand to standard noexcept specifications; when false, they expand to empty, avoiding the IAR build error.

Verify that this change doesn't adversely affect other supported compilers. Run the following script to check for any direct usage of noexcept (not via macros) in the codebase:


🏁 Script executed:

#!/bin/bash
# Description: Find any direct usage of noexcept keyword that might need similar treatment

# Search for noexcept keyword usage outside of macro definitions
rg -n --type=cpp --type=c -g '!platform.h' '\bnoexcept\b' -C2

Length of output: 148


🏁 Script executed:

#!/bin/bash
# Search for direct usages of noexcept outside the macro definitions,
# excluding include/etl/platform.h
rg -n --type=c --type=cpp '\bnoexcept\b' -C2 --glob '!include/etl/platform.h'

Length of output: 148


🏁 Script executed:

#!/bin/bash
# Search for direct usages of noexcept outside platform.h without type filters
rg -n 'noexcept\b' -C2 --glob '!include/etl/platform.h'

Length of output: 148


🏁 Script executed:

#!/bin/bash
# Broad search for any direct usage of noexcept in the codebase
rg -n 'noexcept\b' -C2

Length of output: 41748


Use ETL_NOEXCEPT instead of raw noexcept
Direct noexcept occurrences (e.g. in test files and include/etl/data.h) bypass the new conditional and may still break IAR when exceptions are disabled. Replace them with ETL_NOEXCEPT or ETL_NOEXCEPT_EXPR as appropriate.

🤖 Prompt for AI Agents
In include/etl/platform.h around lines 334 to 340, raw uses of the C++ keyword
noexcept are still present elsewhere (e.g. test files and include/etl/data.h)
and will bypass the ETL conditional macros when exceptions are disabled; search
for all direct occurrences of "noexcept" and replace them with ETL_NOEXCEPT, and
replace instances that use noexcept(...) with ETL_NOEXCEPT_EXPR(...), making
sure the file includes include/etl/platform.h (or otherwise has those macros
visible) so builds targeting IAR with ETL_USING_EXCEPTIONS disabled use the
conditional definitions.

@jwellbelove jwellbelove changed the base branch from master to pull-request/#1195-Added-conditional-support-of-noexcept-to-fix-IAR-support October 3, 2025 07:43
@jwellbelove jwellbelove merged commit 15cbb12 into ETLCPP:pull-request/#1195-Added-conditional-support-of-noexcept-to-fix-IAR-support Oct 3, 2025
83 checks passed
jwellbelove pushed a commit that referenced this pull request Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants