Next: , Previous: Initialization, Up: Preparation


5.1.3 Version Check

It is often desirable to check that the version of `Libshishi' used is indeed one which fits all requirements. Even with binary compatibility new features may have been introduced but due to problem with the dynamic linker an old version is actually used. So you may want to check that the version is okay right after program startup.

shishi_check_version

— Function: const char * shishi_check_version (const char * req_version)

req_version: version string to compare with, or NULL

Check that the version of the library is at minimum the one given as a string in req_version.

Return value: the actual version string of the library; NULL if the condition is not met. If NULL is passed to this function no check is done and only the version string is returned.

The normal way to use the function is to put something similar to the following early in your main:

       if (!shishi_check_version (SHISHI_VERSION))
         {
           printf ("shishi_check_version failed:\n"
                   "Header file incompatible with shared library.\n");
           exit (EXIT_FAILURE);
         }