philbowles / h4plugins

Adds GPIO handling, WiFi, MQTT, Webserver to H4 timer/scheduler. Multi-Platform plugins adding everything needed to create your own multi-function IOT firmware.
45 stars 17 forks source link

What is the STAG() macro used for? #22

Open julianrendell opened 2 years ago

julianrendell commented 2 years ago

I'm working with a student to make an ArtNet service plugin...

We've come across the STAG macro- https://github.com/philbowles/h4plugins/search?q=STAG

Couple of questions:

Thanks in advance!

HamzaHajeir commented 2 years ago

Hi It's intended to define a function that returns the exact passed literals as c-string.

#define STAG(x) constexpr const char* x##Tag(){ return #x; }

So a STAG(all) call defined a function as following:

constexpr const char* allTag(){ return "all"; }

It's intended to standardize the tags used, and to raise a compilation error if one isn't spelled correctly. so if happened that someone typed alTag(), it'll give a compilation error because it's not defined.