ofxPDSP Example failing to compile

Hi - I’m a newb to OF, but am really enjoying exploring its possibilities. I tried to compile the first ofxPDSP example and am getting the following error:


/home/chris/Dropbox/OF/addons/ofxPDSP/src/messages/ExtSequencer.cpp: In destructor ‘pdsp::ExtSequencer::~ExtSequencer()’:
/home/chris/Dropbox/OF/addons/ofxPDSP/src/messages/ExtSequencer.cpp:11:10: error: ‘size_t’ was not declared in this scope; did you mean ‘std::size_t’?
   11 |     for (size_t i = 0; i < instances.size(); ++i) {
      |          ^~~~~~
      |          std::size_t
In file included from /usr/include/c++/11/bits/stl_algobase.h:59,
                 from /usr/include/c++/11/vector:60,
                 from /home/chris/Dropbox/OF/addons/ofxPDSP/src/messages/ExtSequencer.h:9,
                 from /home/chris/Dropbox/OF/addons/ofxPDSP/src/messages/ExtSequencer.cpp:2:
/usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:280:33: note: ‘std::size_t’ declared here
  280 |   typedef __SIZE_TYPE__         size_t;
      |                                 ^~~~~~
/home/chris/Dropbox/OF/addons/ofxPDSP/src/messages/ExtSequencer.cpp:11:24: error: ‘i’ was not declared in this scope
   11 |     for (size_t i = 0; i < instances.size(); ++i) {

Any thoughts on what I could be doing wrong? Is this a version problem? I’m using 0.11.2.

Hi, either change everywhere it says size_t for std::size_t or put that the begining of that file, after all the #includes, using namespace std;

Thanks - that did it. Should have read the actual error message! I guess I was assuming that the library itself couldn’t have the error and I must be doing something really dumb. Since I couldn’t find any reference to the error and ofxPDSP, is it still possible it was something I was doing? If not, assume I should report the bug?

You did nothing wrong. OF used to have the line using namespace std; as a default but since it is considered to be a bad practice it got removed.
Feel free to open an issue in ofxPDSP github repo.
Or maybe @npisanti might want to add something here

i did test compiling ofxPDSP to that version of oF and i had no problem (linux/gcc), but @roymacdonald is right, i thought size_t was the c typedef instead of a c++ standard library typedef and so i didn’t use std:: before it. I’ve refactored ofxPDSP code just now and uploaded the changes to github so there shouldn’t be any problem like this in the future.

2 Likes