The strange case of cvAddSearchPath

Recently, I saw some code that should clearly give a compile error, but it compiled correctly. Here it is:

#include <opencv/highgui.h>

int main()
    // Other code here


    // Other code here

    return 0;

I saw that input_directory was not defined anywhere in this file. I also checked highgui.h and any other files it included. No sign of input_directory anywhere.

The answer came not by pursuing input_directory, but going after cvAddSearchPath. It turns out that this is an obsolete function, but OpenCV has retained it so that old code did not break. The reason this code compiled without any errors, is because cvAddSearchPath was defined to nothing in highgui_c.h:

*                              Obsolete functions/synonyms                               *
#define cvAddSearchPath(path)

Tried with: OpenCV 2.4.9 and Ubuntu 14.04


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s