The following is a code snippet, and the basis of my query.
#define ENGLISH EN
#define FRENCH FR
#define SPANISH ES
#define PORTUGUES PT
#define GERMAN DE
const static char lang_EN[] PROGMEM = "English";
const static char lang_FR[] PROGMEM = "Français";
const static char lang_ES[] PROGMEM = "Español";
const static char lang_PT[] PROGMEM = "Português";
const static char lang_DE[] PROGMEM = "Deutsche";
const static char* const lang_i18n[] PROGMEM = {
#ifdef ENGLISH
lang_EN,
#endif
#ifdef FRENCH
lang_FR,
#endif
#ifdef SPANISH
lang_ES,
#endif
#ifdef PORTUGUES
lang_PT,
#endif
#ifdef GERMAN
lang_DE,
#endif
};
const uint8_t numLang = ArrayCount(lang_i18n); //((sizeof(lang_i18n) / sizeof(lang_i18n[0])) - 1);
const uint8_t numLangElements = numLang + 1;
Does anyone know if it is possible to "loop" through the different defined languages without having separate ifdefs?
My goal is to be able to remove the ifdefs and replace them with a loop of some kind to make adding or removing languages easier/less time consuming.
Before anyone asks: I can NOT post all the code as the program is over 7000 lines.
The pre-processor does not have ANY looping constructs. It parses the file line-by-line, in a forward direction only.
Regards,
Ray L.
Alain74Martel:
Before anyone asks: I can NOT post all the code as the program is over 7000 lines.
There is a standard solution to that, which is explained in the sticky threads at the top of the forum - you can add a long program to a post as an attachment. It is perfectly acceptable.
aarg:
There is a standard solution to that, which is explained in the sticky threads at the top of the forum - you can add a long program to a post as an attachment. It is perfectly acceptable.
Even better to make an MRE. That way people don't have to wade through a bunch of irrelevant clutter to look at the problem. And, many times in making the MRE, you'll discover the problem yourself.
ONCE AGAIN I WILL NOT BE INCLUDING REMAINING SOURCE CODE.
It is irrelevant to the current query.
Thank you RayLivingston for answering somewhat the question.
Alain74Martel:
ONCE AGAIN I WILL NOT BE INCLUDING REMAINING SOURCE CODE.
It is irrelevant to the current query
People who have an unknown problem, typically don't know where it resides. If they did, they would not have a problem.
Also, a BAD ATTITUDE is not conducive to getting help.
aarg - It is not a problem, code works fine.
The question is about optimizing the code to make it easier to implement multiple times.
gfvalvo - I had already stated that I would not include the rest of the code.
And your first suggestion was to include the rest of the code.
Both of you are not giving any help or positive feedback. Code vultures/trolls.
You could both learn from RayLivingston at least he was able give an intelligent answer,
even if I was hoping to get something different.
Alain74Martel:
gfvalvo - I had already stated that I would not include the rest of the code.
And your first suggestion was to include the rest of the code.
No, go back and look, my request was to post an MRE.
Reason being is that I prefer not to post incorrect advice on the forum. So, I don't post code suggestions unless I can compile and test my answers. Since you couldn't be bothered to post a short, but complete, example, I lost interest.
Believe me, I have no desire to see your 7000 lines of code. First, because it's too difficult to wade through that much clutter to the real problem. And second, I have my doubts that it's that good to begin with. I hate looking at ugly code, it makes my brain bleed.
I only corrected a misconception about the forum mechanics that you had - when I do that, I'm responding not only to the person who has posted, but everyone else that reads it. I did not ask you to modify your post.