here "-DVERSION=1.2" will be usable as float, for example by using in the code:
float revision = VERSION
so to make it string we can use conventional float to string tools.
But how to get a library revision such as 0.10.6 from the library.json into the code?
There is multiple problems here :
how to avoid copy paste the revision number on the library.json into a -DVERSION=*.*.* using a version variable or something?
how to pass the value in a define as a string? Indeed -DVERSION=0.10.6 for example cause a compilation error because it’s considered as a float with too many ‘.’ in it. I also try -DVERSION=v0.10.6 but it fails too. We have to find a way to specify it as a string and I don’t get any way for now.
Luos lib have to be able to get Luos and Robus revision. For Luos revision the STRINGIFY thing make it. But you can only get the defined version from the library.json into .c files of the lib and only .c of the lib.
This is because platformio compile lib as library (**.a), so the -DVERISON=x.x.x is only available into .c and not into .h files of the lib. #defined value are not variables, so after the library compilation the #DEFINE is not available anymore to other code parts.
To make it work I had to put the define into memory in a .c.
Something like :
const char VERSION_ROBUS = VERSION; // which is x.x.x
and put it as externe in a .h making it available for other libs :