Created
February 6, 2024 22:53
-
-
Save derrickturk/2e26b18de7f075b0b069bae63ec24df8 to your computer and use it in GitHub Desktop.
X-macros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
const std::size_t num_buttons = 16; | |
const std::size_t total_buttons = num_buttons + 4; | |
#define FOR_EACH_NUMBER(n) "Button " #n, | |
const char* english[total_buttons] = { | |
#include "numbers.def" | |
"Hat Up", | |
"Hat Down", | |
"Hat Left", | |
"Hat Right", | |
}; | |
#undef FOR_EACH_NUMBER | |
#define FOR_EACH_NUMBER(n) "Knopf " #n, | |
const char* german[total_buttons] = { | |
#include "numbers.def" | |
"Hut Hinten", | |
"Hut Vorne", | |
"Hut Links", | |
"Hut Rechts", | |
}; | |
#undef FOR_EACH_NUMBER | |
int main() | |
{ | |
for (const auto& e: english) | |
puts(e); | |
for (const auto& g: german) | |
puts(g); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FOR_EACH_NUMBER(1) | |
FOR_EACH_NUMBER(2) | |
FOR_EACH_NUMBER(3) | |
FOR_EACH_NUMBER(4) | |
FOR_EACH_NUMBER(5) | |
FOR_EACH_NUMBER(6) | |
FOR_EACH_NUMBER(7) | |
FOR_EACH_NUMBER(8) | |
FOR_EACH_NUMBER(9) | |
FOR_EACH_NUMBER(10) | |
FOR_EACH_NUMBER(11) | |
FOR_EACH_NUMBER(12) | |
FOR_EACH_NUMBER(13) | |
FOR_EACH_NUMBER(14) | |
FOR_EACH_NUMBER(15) | |
FOR_EACH_NUMBER(16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment