The PNG Guide is an eBook based on Greg Roelofs' book, originally published by O'Reilly.


We'll turn now to the PNG-specific back-end code in writepng.c. As with any module that calls libpng functions, it begins by including the png.h header file, which in turn includes zlib.h. This particular program also includes writepng.h, which defines our mainprog_info struct, various text-related macros, and prototypes for the externally visible functions that we'll be discussing in detail. Indeed, the first of these functions is almost trivial:

#include "png.h"       /* libpng header; includes zlib.h */
#include "writepng.h"  /* typedefs, common macros, public prototypes */

void writepng_version_info()
  fprintf(stderr, "   Compiled with libpng %s; using libpng %s.\n",
    PNG_LIBPNG_VER_STRING, png_libpng_ver);
  fprintf(stderr, "   Compiled with zlib %s; using zlib %s.\n",
    ZLIB_VERSION, zlib_version);

writepng_version_info() simply indicates the versions of libpng and zlib with which the application was compiled, as well as the versions it happens to be using at runtime. Ideally the two pairs of version numbers will match--in the case of a statically linked executable, they always will--but if the program was dynamically linked, it is possible that the program loader has found either an older or a newer version of one or both libraries, in which case strange problems may arise later. Making this information easily available to the user, whether in a simple text-mode usage screen as I do here or via a windowed ``about box'' or even a fancy, automated, troubleshooting function, can be helpful in dealing with the bug reports that inevitably show up sooner or later.

Last Update: 2010-Nov-26