6 years ago
Hi,
I have a little problem. I created a simple program to display an image. I store the "palette" image in assets.ino file to call it in the first file. When I compile, the IDE detects an error and indicates.
'palette' was not declared in this scope
Yet in other programs that I have downloaded and where it is the same principle, it works. Why do I have this problem?
NEW 6 years ago
you have to pre-declare in the file you use it. If your palette was defined with `Color palette[] = {...};` then that pre-declaring looks like `extern Color palette[];`
NEW 6 years ago
Thanks
But palette is the name of my bitmap I take for make my bitmap exemple ^^
I'm not try to use color palette but just insert my bitmap :)
NEW 6 years ago
so it is something of type Image? Then you need to pre-declare with `extern Image palette;`
I hope you see the pattern here so that you know how to pre-declare any variable
Max
6 years ago
Thank you for the advice, it works great :)
But I'm still wondering how others get there without having to declare with "extern Image ..." as in the game Oubliettes !
NEW 6 years ago
Thank you for the advice, it works great :)
But I'm still wondering how others get there without having to declare with "extern Image ..." as in the game Oubliettes !
Sorunome
6 years ago
It seems like this issue is bound for them to happen eventually, too.....the thing is, when compiling the arduino IDE combinds all .ino files into one large file. If his image happens to be normally declared before he uses it everything is fine, else you get the error you are having atm. So yeah, adding the extern stuff basically guarantees you won't run into such "random bugs" down the road
NEW 6 years ago
It seems like this issue is bound for them to happen eventually, too.....the thing is, when compiling the arduino IDE combinds all .ino files into one large file. If his image happens to be normally declared before he uses it everything is fine, else you get the error you are having atm. So yeah, adding the extern stuff basically guarantees you won't run into such "random bugs" down the road