I'm creating software for an Linux + AVR Arduino project. Obviously the whole work is split in several projects in Eclipse (I'm not using Arduino IDE). I'd like to use common, mostly string, constants for all those projects. I also have to spare microcontroller's RAM so compile-time constants needed. How do I best implement it? My idea is to create a separate, header-only, project for those constants.
Using:
class A {
public:
static const char * const STRING;
static const unsigned char BOOL;
};
is not good enough, because I'd like to be able to concatenate string constants like this:
class A {
public:
static const char * const STRING_PART1;
static const char * const STRING_PART2;
static const unsigned char BOOL;
};
const char * const A::STRING_PART1 = "PART1_";
//const char * const A::STRING_PART2 = A::STRING_PART1 + "PART2"; //obviously won't compile
//const char * const A::STRING_PART2 = strcat("PART2", A::STRING_PART1); //this is not compile-time
I also don't want to use define
. I'd like to use:
class A {
public:
static const std::string STRING_PART1;
static const std::string STRING_PART2;
}
which allows for string concatenation and is (AFAIK) compile-time, but std::string is not available in avr projects - or I'm wrong here and just don't know how to use it.
Any help appreciated.