Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions L2_Core/utils/inc/ek_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ typedef void (*_ek_export_init_fn_t)(void);
const _ek_export_init_fn_t __init_##fn##prio __attribute__((used, section(".ek_export_fn." _EK_STR(prio)))) = \
(fn)

# define EK_EXPORT_HARDWARE(fn) EK_EXPORT((fn), 0)
# define EK_EXPORT_COMPONENTS(fn) EK_EXPORT((fn), 1)
# define EK_EXPORT_APP(fn) EK_EXPORT((fn), 2)
# define EK_EXPORT_USER(fn) EK_EXPORT((fn), 3)
# define EK_EXPORT_EARLIEST(fn) EK_EXPORT(fn, 0)
# define EK_EXPORT_HARDWARE(fn) EK_EXPORT(fn, 1)
# define EK_EXPORT_COMPONENTS(fn) EK_EXPORT(fn, 2)
Comment on lines +61 to +63

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

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

这些 EK_EXPORT_* 便捷宏会把 fn 传入 EK_EXPORT,而 EK_EXPORT 会在符号名里做 __init_##fn##prio 的 token-paste;因此 fn 实际上必须是“函数名标识符”,不能是任意函数指针表达式(例如 &fn、强转、括号包裹的表达式等),否则会触发预处理/编译错误。建议在这些宏附近补充注释/文档,明确 fn 的用法约束。

Copilot uses AI. Check for mistakes.
# define EK_EXPORT_APP(fn) EK_EXPORT(fn, 3)
# define EK_EXPORT_USER(fn) EK_EXPORT(fn, 4)
Comment on lines +61 to +65

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

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

EK_EXPORT_HARDWARE/COMPONENTS/APP/USER 的优先级值整体 +1(硬件从 0 变成 1 等),会改变启用 EK_EXPORT 时的初始化调用顺序;如果已有代码依赖旧的宏优先级,这会造成行为变化。建议至少在头文件中明确说明该优先级映射已变更,或提供兼容旧映射的别名宏以避免静默破坏。

Copilot uses AI. Check for mistakes.

#else

# define EK_EXPORT_EARLIEST(fn)
# define EK_EXPORT(fn, prio)
# define EK_EXPORT_HARDWARE(fn)
# define EK_EXPORT_COMPONENTS(fn)
Expand Down
Loading