Skip to content

nrfx: drivers: avoid using c23 unnamed parameters#144

Open
ItsShunya wants to merge 1 commit into
nordicsemi:masterfrom
ItsShunya:c17_compat
Open

nrfx: drivers: avoid using c23 unnamed parameters#144
ItsShunya wants to merge 1 commit into
nordicsemi:masterfrom
ItsShunya:c17_compat

Conversation

@ItsShunya

Copy link
Copy Markdown

During the 4.0.0 update, many macros to generate IRQ handlers had their function signature updated to accept a pointer as parameter, which is typically used in some vector tables for passing some context.

The way it was done was leaving the parameter unnamed in the macros, which is a feature added in C23. This breaks compatibility with older C versions. My suggestion is to simply add p_context to keep a name for the parameter so nrfx does not complain in

Using C23 unnamed parameters for function definitions breaks C11/C17 compatibility.
@CLAassistant

CLAassistant commented Jan 16, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@nika-nordic nika-nordic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

left some formatting-related comments.

We have also added this "imperfection" to the scope of next nrfx release, so you can also disregard this review and wait for next nrfx release. Thanks!

Comment thread drivers/nrfx_common.h
@@ -97,7 +97,7 @@ extern "C" {
#define NRFX_RELEASE_VER_MICRO 1

/** @brief IRQ handler type. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

p_context needs documentation in Doxygen block, as done for driver-specific handlers

Comment thread drivers/nrfx_utils.h
#define NRFX_INSTANCE_IRQ_HANDLER_DEFINE(periph_name_small, inst_idx, p_instance) \
void NRFX_CONCAT(nrfx_, periph_name_small, _, inst_idx, _irq_handler)(void *) \
void NRFX_CONCAT(nrfx_, periph_name_small, _, inst_idx, _irq_handler)(void * p_context) \
{ \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

subsequent \ should be aligned to match column of \ in the modified line (also in the line above)

*/
#define _NRFX_IRQ_HANDLER(periph_name, prefix, i, periph_name_small) \
void NRFX_CONCAT(nrfx_, periph_name_small, _, prefix, i, _irq_handler)(void *) \
void NRFX_CONCAT(nrfx_, periph_name_small, _, prefix, i, _irq_handler)(void * p_context) \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as above - \ should be aligned to the same column

@mstasiaknordic

Copy link
Copy Markdown

Hi @ItsShunya, this issue has been fixed with the new nrfx 4.2.0 release. Please check if this answers your problem.

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.

4 participants