I am struggling to define structs and use them as return values and pass them as arguments to my class methods. I keep getting a string of errors:
TMGPS.cpp:6:1: error: 'UBX_MESSAGE_TYPE' does not name a type
UBX_MESSAGE_TYPE getPacketMessageType (UBX_MSG_CHECKSUM_HEADER pHeader, UBX_MESSAGE_TYPE msgTypes[]){
exit status 1
'UBX_MESSAGE_TYPE' does not name a type
Please if anyone could help? Below is a slimmed down version of my code. I am aware that my return data is pointless, but is just as an example.
Will your application code (.ino and/or other .cpp files) be calling the getPacketMessageType() function? If so, the UBX_MESSAGE_TYPE type needs to be public.
I'm not sure what will happen when you try to return the value of a local variable of type UBX_MESSAGE_TYPE that contains a std:string member (since it surely has dynamically allocated data). Hopefully the return value will be copy-constructed (or move-constructed) from your local variable 'msgTypes'.
I believe the only problem was the missing scope on the function definition. I don't believe it's needed on the UBX_MESSAGE_TYPE type declarations. The function automatically has the same scope as the struct. This should work:
Thank you, thank you, thank you! I tried prefix tmGPS:: to return type and the moved it to the method name, I didn't try add it to both. I did it and all compiles.