Hello
I am attempting to change a constant variables value, *yes I am aware of the contradiction of what I am doing* but there is a method to my maddness.
You see I am writting in a language very similar to C/C++ called 4dm but it doesn't allow any code outside of functions so I am trying to overcome this by using pre-processor commands. The reason is so I can achieve a form of specialisation in the language. The first step of this involves being able to edit a constant string.
Even though this is a different language, the preprocessor operates in exactly the same way as C and C++ compilers:
#define MY_STR "abc"
#define CONCAT(s) \
#define TEMP MY_STR \ // store MY_STR in TEMP_STR
#undef MY_STR \ // undefine MY_STR
#define MY_STR TEMP s // redefine MY_STR so it contains the old value plus the new one
CONCAT(def)
printf("%s\n", MY_STR); // should hopefully print out "abc def"
The following is a simple attempt at concatenating a string but I get a compile error saying `MY_STR is not defined` any ideas how to fix this?
#define MY_STR abc
#define TEMP MY_STR
#undef MY_STR
#define MY_STR TEMP def
void test()
{
print(MY_STR);
}