0

I am trying to use #define in Arduino IDE as I used to do in Atmel Studio like:

#define PROGRAM(N) void PROG_##N(void)

However I am getting a stray error because of the hashes, is there a way to implement this better?

Aim: PROGRAM(5){} becomes void PROG_5(void){} and so on.

  • It compiler in my Arduino IDE. Code: (using \n as newlines): #define PROGRAM(N) void PROG_##N(void) \n PROGRAM(5){}\n void setup(){}\n void loop(){} – Michel Keijzers Aug 28 at 12:48
  • What version of the IDE are you using? You're not a Linux user that used apt-get to install it are you? – Majenko Aug 28 at 14:57
  • It is working now, the mistake was actually in a different file but Arduino IDE 1.8.8 kept saying it is here which was confusing. Thanks. – Mustafa Otbah Aug 31 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.