Can #define preprocessor take parameters?
-
Setting
#define PRINT(a) Console.print(#a)
and then calling PRINT(hello) or PRINT("hello") returns "macro parameter amount mismatch". I feel like this is telling me that there's a parameter where it shouldn't be. Am I right?
Docs point to this page https://www.tutorialspoint.com/cprogramming/c_preprocessors.htm but otherwise don't provide examples on using #define in HISE.
I'm still getting the hang of HISEScript so please let me know if I missed something.
-
Alright,
#define DECLARE_REG(name) reg name DECLARE_REG(test) = 5.767;
works as expected. No space between identifier and open parenthesis, got it.
This compiles in C and prints the value, with the variable test_heyhey properly formed from two tokens.
int main() { #define DECLARE_REG(name) int name ## _heyhey DECLARE_REG(test) = 69; printf("%d", test_heyhey); return 0; }
When I try this in HISE, I try
#define DECLARE_REG(name) reg name ## _heyhey DECLARE_REG(test2) = 69.6969;
and get an error saying "Unexpected character '#' in source"
How to do #define token concatenation in HISEScript, then? @Christoph-Hart