@@ -101,6 +101,12 @@ struct command {
const char *usage;
};
+#if defined(__has_attribute) && __has_attribute(retain)
+#define start_stop_retain __attribute__((retain))
+#else
+#define start_stop_retain
+#endif
+
#define COMMAND_NAMED(_type, _name, _abbr, _handler, _flags, _arg, _usage) \
static const struct command command_ ## _name ## _ ## _type = { \
.type = (_type), \
@@ -112,7 +118,7 @@ struct command {
.usage = (_usage), \
}; \
static const struct command *__command_ ## _name ## _ ## _type \
- __attribute__((__used__,__section__ ("__command"))) = &command_ ## _name ## _ ## _type
+ __attribute__((__used__,__section__ ("__command"))) start_stop_retain = &command_ ## _name ## _ ## _type
#define COMMAND(_type, _handler, _abbr, _flags, _arg, _usage) \
COMMAND_NAMED(_type, _handler, _abbr, _handler, _flags, _arg, _usage)