The error occurs as the first RGB* foreground; giving “error: ‘RGB’ does not name a type”. I can understand that declaring an OBJECT of a class inside the same class is not allowed, I don’t understand why the function declaration is not working. Moreso, why does it work on Arduino!?
Well, I am not the guru but I remerber trying somthing like this a while a go. And I had to put the classes in different libraries. Why not give it a try
@peekay
in the IDE, define a different lib. The ide stores the classes “lib’s” in different directories. I learned this when I received a backup of my code from Particle. The application is stored in a top dir, and all lib’s are stored in different subdir’s. containing the .h and .cpp file
I split the RGB class def into RGB.h and the class functions into RGB.cpp, fixed the includes all around and I still get the same errors. The RGB class is just not getting defined for some reason.
Hold a min, there already is an RGB object (RGB.control() …) in the Particle world - is this getting in your way (with an obscure error message tho’)?
@peekay123, if you wrap your lib in a namespace WhatEver and use WhatEver::RGB* foreground; or use namespace WhatEver any ambiguities should be resolved.
typedef class RGB {
int var;
public:
void f(){};
private:
void q(){};
} rgb_t;
class PixelsBase {
rgb_t* foreground;
//foreground->f(); //error <-- this is not allowed in a class definition
//foreground->var =0; //error <-- ditto
};
Actually no, these are not the same error messages as Paul was seeing.
You, are putting "active code" (function call and pointer deref) where only declarations are allowed.
It's not a class vs. struct thing, the reason why the typedef works is because it also resolves above ambiguity.
I did what you did too, and the solution is that RGB in capitals is apparently a name used by the firmware, I tried ‘rgb’ with small letters, and that compiled.
@marcus, @ScruffR, I had done a search for the RGB stuff in the firmware and totally missed it!! When I renamed the entire RGB class and references to RGBp instead, it all compiled. Thanks for your help folks! This community rocks as usual.
BTW, the code I am porting is for the Pixels graphics library