I want to invoke a macro by building its name during runtime. I want to have a list of macros that follow the same name rule `ERROR_MSG_X` where X is the error code and to invoke them according to a variable. I have the following function:

```cpp
void    print_error(int e)
{
    printf("[ERROR] : code (%d)\n\t%s", e, ERROR_MSG_#e); //not proper syntax
}

```

The header would be something like:

```cpp
# define ERROR_MSG_1 "Failed to open file.\n"
# define ERROR_MSG_2 "Failed to read file.\n"
# define ERROR_MSG_3 "Failed to execute abc.\n"
...

```

I tried messing with `#` and `##` but didn't get the results I wanted.

I have a lot of constraints on what I can and can't do such as no external functions, no multiline macros, no parameterized macros, no global variables, etc. Is there a way to calculate the name of the macro with the value passed or do you have another suggestion on how to do this? I could have an array with the msgs and pass it to the function but I really didn't want to do it that way plus I would have to have the error codes sequential or waste memory to store them.