ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Воскресенье
5 мая
1222832 Топик полностью
il-2 (12.07.2022 16:38, просмотров: 267) ответил Nikolay801_ на есть метод енум в строку преобразовать?
Можно и нужно, это касается не только строк, а любых ресурсов: 
rc_message.h

_RC_MESSAGE( MSG_YES, "Да", "Yes", "Ja" )

_RC_MESSAGE( MSG_NO, "Нет", "No", "Nain" )

....


message.h

#define _RC_MESSAGE(label, ...) label,

enum _msg_id

{

#include "rc_message.h"

_MSG_COUNT_

};

#undef _RC_MESSAGE

message.c

#define _RC_MESSAGE(label, l_ru, l_en, l_de) static uint8_t const ru_##label[] = l_ru;

#include "rc_message.h"

#undef _RC_MESSAGE

#define _RC_MESSAGE(label, l_ru, l_en, l_de) static uint8_t const en_##label[] = l_en;

#include "rc_message.h"

#undef _RC_MESSAGE

#define _RC_MESSAGE(label, l_ru, l_en, l_de) static uint8_t const de_##label[] = l_de;

#include "rc_message.h"

#undef _RC_MESSAGE


#define _RC_MESSAGE(label, ...) ru_##label, en_##label, de_##label,

static uint8_t const *msg_base[_MSG_COUNT_ * 3] =

{

#include "rc_message.h"

};

#undef _RC_MESSAGE


uint8_t const *GetMessage(enum _msg_id message_id, uint8_t lang_id)

{

return msg_base[message_id * 3 + lang_id];

}