Compilation problem with image

Général

Max

il y a 6 ans

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?

testeur_image.zip

Sorunome

NEW il y a 6 ans

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[];`

Max

il y a 6 ans

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 :) 

Max

NEW il y a 6 ans

Sorunome Sorunome

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 :) 

Sorunome

il y a 6 ans

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

Sorunome

NEW il y a 6 ans

Max Max

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

il y a 6 ans

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 !

Max

NEW il y a 6 ans

Sorunome Sorunome

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

il y a 6 ans

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

Sorunome

NEW il y a 6 ans

Max Max

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