I have this macro for start packet's
#define BEGIN_PACKET_DEF(name, type) typedef struct name {\
int8_t header;\
static size_t size() { return sizeof(name); }\
name() { memset(this, 0, sizeof(name)); header = type; }
And this for ending packet's
#define END_PACKET_DEF(name) } name;
And i want to change it as a c++ function.
As name says is an define to start packet definition
The BEGIN_PACKET_DEF
will add auto the int8_t header;
in each packet
Example usage :
BEGIN_PACKET_DEF(Name_struct,HEADER)
// some packet's data
END_PACKET_DEF(Name_packet)
I need some help to rewrite those macro as C++ functions and to do same effect like macros, I just don't like to use macros.