Declare a variable and add it to an array at compile time
问题 I'd like to get a C macro (or several) that could serve two purposes: Declare a const variable. Add that variable to an array. I.e , if I have this typedef struct { int port; int pin; } pin_t; A macro like this #define DEFINE_PIN(name, port, num) should expand to something like this #define NAME port, num const pin_t[] = { {NAME} }; And each definition should append the new defined variable to the array. I know that a #define cannot expand to #define s but is just an illustration. What I want