Hi
I'm working with the Nano 33 IoT and I noticed that when I put certain constants in program memory, everything keeps working when I use the ordinary sprintf, strlen, strcmp, ... functions instead of the ..._P equivalents.
Sample declarations / definitions:
In he class header file:
class MyClass {
...
struct FuncDefs {
const char* funcname;
char minArgs;
char maxArgs;
};
In the class code file:
PROGMEM const MyClass::FuncDefs MyClass::_functions []
{{"t00",0 ,0}, {"t01",0 ,1}, {"t02", 0,2}, {"t11",1 ,1}, {"t12",1 ,2}};
This works (pNext and pch are character pointers):
if ( strlen( _functions [funcIndex].funcname ) != pNext - pch ) { doSomething(); }
if ( strncmp( _functions [funcIndex].funcname, pch, pNext - pch ) != 0 ) { doSomething(); }
This works as well:
char _minA ,_minB;
_minA = _functions [funcIndex].minArgs;
_minB = _functions [funcIndex].maxArgs;
My question: what's the purpose of the ..._P equivalents then ? Or is isn't it safe what I'm doing, even if this works ?
Could not find anything on this topic, so I hope you can help me out here. Thanks !