The pubsubclient3 library calls strnlen(). An easy workaround is to include strnlen in the sketch.
// Required for Uno Q/Zephyr Core. Remove when core is fixed.
size_t strnlen(const char* b, size_t s) {
size_t i;
if ((b == NULL) || (s == 0)) return 0;
for (i = 0; (i < s) && (b[i] != 0); i++);
return i;
}
Out of curiosity I tried to just add #include <cstring>
#include <Arduino_RouterBridge.h>
#include <cstring>
void setup() {
//Initialize Monitor and wait for port to open:
Monitor.begin();
delay(5000);
}
void loop() {
const char* str = "Hello, World!";
// Get the length of the string, up to maxLen characters
size_t length = strnlen(str, sizeof(str));
Monitor.print(length);
Monitor.print("\r");
}
but that gives a slightly different error:
<err> llext: Undefined symbol with no entry in symbol table atexit, offset 13732, link section 13
Yes, an array name can be used as a pointer to its first element. But they are not the same thing. The type of this identifier is interpreted by the compiler depending on the context. For example, when working with individual array elements, the array name is converted to a pointer to the element.
char s[]="hello";
char* a = s+1; // pointer to s[1]
Meanwhile, functions like sizeof() works with it as an entire array, which allows them to be used in a well-known expression for calculating the number of elements.
From the write-up style of @b707 in post #9, it appears that sizeof() is being called/named a function. Within the forum discipline, I believe that I have the liberty to ask the poster whether this interpretation is correct or if it was simply a typo mistake.
I suspect that you already know that sizeof is part of the C/C++ language and is an operator, so why not just point that out instead of asking the question ?
To be honest, I didn't know it before @UKHeliBob answer.
Why do you consider this difference important in the context of my message about array and pointers?