openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.98k stars 2.55k forks source link

ofImage needs to include "ofPixels.h" #8071

Closed 2bbb closed 3 months ago

2bbb commented 3 months ago

simple sample code with error.

#include "ofImage.h"

struct X {
    ofImage image;
};

and error message is: "libs/openFrameworks/graphics/ofImage.h:643:26 Implicit instantiation of undefined template 'ofPixels_'"

this is caused by ofPixels is only declared without definition.

if it is needed to fix, I will create PR.

danoli3 commented 3 months ago

ofPixels should be included by ofImage

dimitre commented 3 months ago

I've seen ofPixels.h is included in ofImage.cpp file. are you using latest @2bbb ?

2bbb commented 3 months ago

@dimitre sorry, my explanation and code sample were not good. the problem is caused on ofImage.h.

because ofImage has instance of ofPixels. if ofImage has pointer, shared pointer, or reference of ofPixels then forward declaration is good way to reduce header dependencies. but relation of ofImage and ofPixels is not so.

therefore, ofImage.h needs to ofPixels.h

dimitre commented 3 months ago

Great. feel free to make the PR, I was trying to reduce the .h included in other .h files but it seems it was not a good idea there!

2bbb commented 3 months ago

OK! I will create PR soon!