Fixing "no return statement in function returning non-void" and warning: "control reaches end of non-void function"

hello everybody, I’m porting an addon (ofxTimeline) to get it working with the latest OF master.
At the moment, there are a lot of errors for methods that do not return anything. Something like this for example is braking:

static GLint glTypeForImageType(int imageType){
      if(imageType == OF_IMAGE_GRAYSCALE) return GL_LUMINANCE;
      if(imageType == OF_IMAGE_COLOR) return GL_RGB;
      if(imageType == OF_IMAGE_COLOR_ALPHA) return GL_RGBA;

To fix it, I have to explicitly return a value, like this

static GLint glTypeForImageType(int imageType){
    int val = 0;
    if(imageType == OF_IMAGE_GRAYSCALE) {val = GL_LUMINANCE;}
    if(imageType == OF_IMAGE_COLOR) {val = GL_RGB;}
    if(imageType == OF_IMAGE_COLOR_ALPHA) {val = GL_RGBA;}
    return val;

The main problem is that sometimes is difficult what the developer wanted to achieve with a method that does not return anything, like in this case:

bool ofxTLPageTabs::keyPressed(ofKeyEventArgs& args){

For now, the solution that I have adopted is to use EXIT_SUCCESS for those cases

bool ofxTLPageTabs::keyPressed(ofKeyEventArgs& args){
    return EXIT_SUCCESS;

Is this correct? is there a better way to handle this cases?

I do not think I’m doing it right because after fixing all the errors I receive this message:

15:33:40: Running steps for project example-timelineLib…
15:33:41: Could not start process “”
Error while building/deploying project example-timelineLib (kit: Desktop)
When executing step “Custom Process Step”
15:33:41: Elapsed time: 00:01.

at least for bool keyPressed(ofKeyEventArgs& args) it should return false as the default otherwise the event propagation will stop.

in glTypeForImageType(int imageType)I would simply add return 0; at the end of the function. It achieves the same as what you have but it only will add a line instead of modifying the whole function body, and it will be one allocation less ( int val = 0; ). Although I guess that it would be more correct to return GL_NONE which is defined as a zero but it could change in the future.

My bad, there was an empty custom step in the build.
I have returned false instead of EXIT_SUCCESS as @roymacdonald was suggesting (thanks Roy!). I will replace ofxTween with ofxEasing, the repository is here

hey @edapx, (@roymacdonald) here you can see that there is a new [working] update ofxTimeline repo:

I tested on VS2017 with OF master branch and it worked!

BTW, I see here that you were planning to update ofxTween. I am interested on this too, because I am using somewhere ofxSphereCam, that uses it.
What are your tips on this? I don’t know if replace ofxTween with ofxAnimatable or ofxEasing… Maybe I can just add some Poco stuff (like on ofxTimeline)… I tried to add ofxPoco… but not working yet.

the link was in that other thread. My reimplementation of ofxTween is named ofxTween2. It requires to use ofxEasing. it does not use poco.
hope this helps.

1 Like

thanks! it worked the replacement for ofxSphereCam.