Search code examples
cheader-files

Passing a #define parameters to class


I have main function which is in one folder and there is one class with some useful functions in another folder. In the main function I have this code:

#include "UsefulFunctions.h" 
#define PRINTINGLINE 0
#if PRINTINGLINE == 1
    #define debug(x) Serial.print(x)
    #define debugln(x) Serial.println(x)
#else
    #define debug(x)
   #define debugln(x)
#endif

I use this so i can save some processor time and memory, and i can easy turn on and off by change one value. But this is in main how can i use this in the UsefulFucntions without make double code and changes on two places?

Thanks a lot


Solution

  • Put the defines in a header and include it where you want to use it. –@Retired Ninja

    Thanks , this did the job . Thanks for everyone who shared their opinion.

    W1zz1 :)

    Can be Locked .