-
-
Notifications
You must be signed in to change notification settings - Fork 469
Added conditional support of noexcept to fix IAR support #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
#define ETL_LVALUE_REF_QUALIFIER & | ||
#define ETL_NOEXCEPT noexcept | ||
#define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) | ||
#if ETL_USING_EXCEPTIONS |
There was a problem hiding this comment.
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)
WalkthroughThe 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)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
There was a problem hiding this 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
📒 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
orfix 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
#if ETL_USING_EXCEPTIONS | ||
#define ETL_NOEXCEPT noexcept | ||
#define ETL_NOEXCEPT_EXPR(...) noexcept(__VA_ARGS__) | ||
#else | ||
#define ETL_NOEXCEPT | ||
#define ETL_NOEXCEPT_EXPR(...) | ||
#endif |
There was a problem hiding this comment.
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.
15cbb12
into
ETLCPP:pull-request/#1195-Added-conditional-support-of-noexcept-to-fix-IAR-support
…t-to-fix-IAR-support' into development
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.