New Code::Blocks 10.05 "exit is not a member" fix

There’s a new version of Code::Blocks available, and when you try to compile the OF emptyExample it says:

error: ‘exit’ is not a member of ‘std’

You can fix this by going into ofConstants.h and changing this line:

#include <stdlib.h>  


#include <cstdlib>  

This is part of a more general weirdness with OF in that it’s mixing C and C++ headers. The C++ headers are backwards compatible with C, so I would recommend changing all the following in ofConstants.h to their C++ equivalents:

#include <stdio.h>  
#include <stdarg.h>  
#include <math.h>  
#include <time.h>  
#include <stdlib.h>  
#include <string.h>  

That is:

#include <cstdio>  
#include <cstdarg>  
#include <cmath>  
#include <ctime>  
#include <cstdlib>  
#include <string>  

Notice that #include is already present, so it can be left out.

Actually, if those changes are made, I’d like to request that this line is added:

#include <fstream>  

So file io can be accomplished easily using streams.

thank you! this and helped getting my app running in new version of Code::Blocks

Also discussed in this thread

Added as an issue to the OF project on github, to be resolved for r62 it seems: