Tool/software: TI C/C++ Compiler
When I declare a global object of a class, such as:
class RxKey : public Base {
public:
RxKey(const char* key_name, const char* str, uint8_t len)
: name(key_name), s(str), l(len) {}
RxKey(const char* str, uint8_t len)
: name(0), s(str), l(len) {}
const char* const name; // regex string
const char* const s; // regex string
const uint8_t l; // minimum buffer length
friend bool operator==(const RxKey& key1, const RxKey* key2);
friend bool operator==(const RxKey* key1, const RxKey& key2);
friend bool operator==(const RxKey& key1, const RxKey& key2);
friend bool operator!=(const RxKey& key1, const RxKey& key2);
// ---- to_string() --------------------------------------------------------
bool to_string(StringS* out) {
if (name != 0) {
return out->push_str(name);
} else if (s != 0) {
return out->push_str(s);
}
return out->push_str("no name");
}
// ---- print() ------------------------------------------------------------
bool to_serial_tx(SerialTXInterface* TX) {
if (name != 0) {
return TX->print(name);
} else if (s != 0) {
return TX->print(s);
}
return TX->print("no name");
}
bool print_help(SerialTXInterface* TX) {
TX->print(s);
if (name != 0) {
TX->print(", ");
TX->print(name);
}
return true;
}
};
Does when the pre-main runs, it calls malloc to instantiate the class, does that mean it is in the dynamic memory space? I thought that only variable that are created using new operator end up on the heap, is that not the case?