I have created a library that contains an array. This is the .h file:
class Lib {
public:
static int arr[];
};
And this is the .cpp file:
#include "Lib.h"
int Lib::arr[] = {0, 1, 2, 3};
When trying to compute the size of this array from within the library, it works just fine. When trying to do this from a sketch, I get the error mentioned in the title. This is the sketch I'm using:
#include <Lib.h>
void setup() {
sizeof(Lib::arr);
}
void loop() {}
What is the problem here?
53, 33, 4, 12
to be sure you do not access the 0 initialized memory atLib:arr[0]
. If you find the correct value, then at least the initialization works. But then, I have no better explanation. Btw: the correct C++ initialization aof static vars isint Lib::arr[4] = {0, 1, 2, 3};
. Perhaps that matters.