My program uses a linked list with a void *data pointer that points to different types of structures. The nodes store the type, so accessing is just a matter of reading *data into a structure of the appropriate type. To do this, I use memcpy. Worked fine in my arduino version, but in IDF I've got some 80 errors like:
Code: Select all
void* memcpy(void*, const void*, size_t)' writing to an object of type 'struct butData' with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]",
Code: Select all
typedef struct fNode
{
void *data;
uint8_t type;
uint16_t flags;
}fNode;
here is what one of the structs looks like:
Code: Select all
typedef struct butData
{
uint8_t ID, type;
uint8_t mouseState:3;
Rect absPos;
int8_t txtStartOffset;
std::string fieldText;
fabgl::FontInfo const* fieldFont;
uint8_t bg0, fg0, bg1, fg1, hoverColor, clickColor;
}butData;
here are the memcpy's I use to read & right to the node data: (read node is a temp instance of fNode, the linked list struct)
Code: Select all
memcpy(&curButData, readNode.data, sizeof(curButData)); // read
memcpy(readNode.data, &curButData, sizeof(curButData)); //write
So first of all, I really need to understand why this wasn't a problem in arduino, and is in IDF? I know arduino framework has its differences, but this seems like straight C++ stuff.
Second, I need to figure out how to correct this. Kinda spinning my wheels on that right now. Do I need to write copy constructors for each of the structures? Do I need to use a different command to copy? Do I actually have a code issue, or do I need to fix something with the compiler? I mean, it all worked fine in arduino....
I can write some code, but I am by no means a programmer. Please keep that in mind with your responses.
Thanks so much for your attention, without community support like this, I could never accomplish the things do.
**on a side note, I had been working to break my use of String(arduino), after I read up on the problems it can make. In replacing all the String references, I used a mix of c and c++ strings (char *str & std::string). After using c++ strings, I saw they can do most of the things a String(ard) can do. Do they come with the same pitfalls of String? If not, why was the adruino String ever made?