Next: , Previous: , Up: Preparation   [Contents][Index]


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: Oldest acceptable version, or NULL.

Description: Checks that the installed library version is at least as recent as the one provided in req_version. The version string is formatted like "1.0.2".

Whenever NULL is passed to this function, the check is suppressed, but the library version is still returned.

Return value: Returns the active library version, or NULL, should the running library be too old.

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);
    }